Skip to content

fix: batch multitenant lifecycle tenants - #1654

Merged
ferhatelmas merged 1 commit into
masterfrom
ferhat/mt-31
Nov 3, 2026
Merged

ferhatelmas merged 1 commit into
masterfrom
ferhat/mt-31

Conversation

@ferhatelmas

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

Multitenant lifecycle registry and trigger are created then it's backfilled for all enabled tenants in one tx. The trigger DDL lock remains for the backfill commits and a failure rolls every progress back.

What is the new behavior?

Commits the registry and trigger first then backfill tenants in batches of up to 1000. The trigger covers new tenants and feature activations during the scan. Lock conflicts are retried up to five times. If a later batch fails, progress from earlier batches remain committed and a a retry can replay the backfill.

Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>
@ferhatelmas
ferhatelmas requested a review from a team as a code owner November 3, 2026 23:11
Copilot AI balanced review requested due to automatic review settings November 3, 2026 23:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the resumable multitenant lifecycle enrollment changes.

No open issues 🎉

What changed in this PR

This PR makes multitenant lifecycle enrollment resumable by committing the registry and trigger before backfilling tenants, reducing lock duration and preserving completed batches if a later batch fails.

Changes:

  • Backfills tenants in batches of up to 1,000, with the trigger covering concurrent inserts and feature activations.
  • Retries schema and backfill lock conflicts with a limit of five attempts.
  • Adds integration tests for lock release, partial recovery, retry limits, enrollment coverage, and migration-hash handling.
File Description
src/​test/​lifecycle-tenants-migration.test.ts Adds tests for batching, concurrency, retries, recovery, and hash compatibility.
migrations/​multitenant/​0031-lifecycle-tenants.sql Separates schema setup from committed backfill batches and adds bounded lock-conflict retries.

Review effort: Balanced

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 41737182380

Coverage increased (+0.07%) to 87.131%

Details

  • Coverage increased (+0.07%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15681
Covered Lines: 14105
Line Coverage: 89.95%
Relevant Branches: 10017
Covered Branches: 8286
Branch Coverage: 82.72%
Branches in Coverage %: Yes
Coverage Strength: 1240.14 hits per line

💛 - Coveralls

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings marked 🟡 are optional suggestions and need no follow-up push.

@ferhatelmas
ferhatelmas merged commit aa78cb2 into master Nov 3, 2026
38 checks passed
@ferhatelmas
ferhatelmas deleted the ferhat/mt-31 branch November 3, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants