Conversation
There was a problem hiding this comment.
Pull request overview
Fixes progressive migration scheduling so it doesn’t get stuck when job emission fails, by ensuring the in-memory queue and emittingJobs state are handled safely across errors and retries.
Changes:
- Updates
ProgressiveMigrations.createJobs()to keep tenants queued on failures, only removing tenants after successful preparation/emission, and always resettingemittingJobsviafinally. - Adds regression tests covering batchSend failures, in-flight batching behavior, duplicate tenant adds, and per-tenant job preparation failures.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/internal/database/migrations/progressive.ts |
Reworks batching/removal semantics to preserve queued tenants on failures and reset emittingJobs reliably. |
src/test/progressive-migrations.test.ts |
Adds focused regression coverage for failure and in-flight queue behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
b6a2bee to
33c98c1
Compare
There was a problem hiding this comment.
Pull request overview
Fixes a progressive migration scheduling bug where the in-memory “emitting” flag could remain stuck after failures, preventing further job emission. The changes adjust the progressive job-emission flow to keep tenants queued until emission succeeds and add regression tests around both progressive batching and the migration worker event handler.
Changes:
- Serialize/guard progressive job creation via an in-flight promise and ensure
emittingJobsis always reset (even on errors). - Keep tenants in the in-memory queue until migration jobs are successfully emitted; retain tenants when job preparation/emission fails.
- Add regression coverage for progressive batching behavior and
RunMigrationsOnTenants.handleoutcomes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/internal/database/migrations/progressive.ts | Refactors progressive batching to be failure-safe (no lost tenants) and to reset the emitting flag reliably via finally. |
| src/test/progressive-migrations.test.ts | Adds regression tests for “keep queued on failure”, “in-flight batch behavior”, and “drain serialization”. |
| src/test/run-migrations-event.test.ts | Adds unit tests for the migrations queue worker handler covering success, short-circuit, lock timeout, and retry/final-failure behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
33c98c1 to
8665931
Compare
There was a problem hiding this comment.
Pull request overview
Fixes progressive tenant migrations getting stuck by ensuring the “emitting” state is always reset and by keeping tenants in the in-memory queue until jobs are successfully emitted.
Changes:
- Refactors
ProgressiveMigrationsjob emission to serialize in-flight emits and only dequeue tenants after successful batch emission. - Adds regression tests for progressive migration queueing/emitting behavior.
- Adds coverage for
RunMigrationsOnTenants.handlesuccess/short-circuit/lock-timeout/retry behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/internal/database/migrations/progressive.ts |
Introduces in-flight serialization and delayed dequeuing for progressive migration job emission. |
src/test/progressive-migrations.test.ts |
Adds regression tests for queue retention, in-flight behavior, and preparation failures. |
src/test/run-migrations-event.test.ts |
Adds tests for the migration job handler’s success and error paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
364b5eb to
a94c29e
Compare
There was a problem hiding this comment.
Pull request overview
Fixes progressive tenant migrations potentially getting stuck by ensuring the “emitting” state is always reset after job creation attempts and by retaining tenants in the in-memory queue until enqueue succeeds, with added regression tests around these behaviors.
Changes:
- Serialize progressive job creation via an in-flight promise and reset
emittingJobsin afinallypath. - Keep tenants queued until
batchSendsucceeds; log and retain tenants when job preparation fails. - Add regression tests for
ProgressiveMigrationsbehavior andRunMigrationsOnTenants.handleretry/failure paths.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/internal/database/migrations/progressive.ts | Reworks progressive job creation to be in-flight/serialized and to retain tenants until successful enqueue. |
| src/test/progressive-migrations.test.ts | Adds regression coverage for queue retention, emitting flag reset, and in-flight serialization edge cases. |
| src/test/run-migrations-event.test.ts | Adds coverage for migration event handling across success, lock-timeout, and retryable failure scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
a94c29e to
3f2a74f
Compare
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
3f2a74f to
3abe0f6
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes progressive migration scheduling reliability by ensuring the “emitting” state is always reset on failure, and by keeping tenants in the in-memory queue until enqueue succeeds, with added regression tests to prevent the scheduler from getting stuck.
Changes:
- Serialize/guard progressive migration job creation with an in-flight promise and always reset
emittingJobsviafinally. - Keep tenants queued until successful enqueue; move prep-failed tenants to the back for retry rather than dropping them.
- Add regression tests for
ProgressiveMigrationsbehavior andRunMigrationsOnTenants.handleoutcomes.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/internal/database/migrations/progressive.ts |
Reworks job creation to be serialized and failure-safe; keeps tenant queue intact until enqueue succeeds. |
src/test/progressive-migrations.test.ts |
Adds regression coverage for queue retention, in-flight serialization, and failure logging/ordering. |
src/test/run-migrations-event.test.ts |
Adds coverage for migration event handler success, short-circuiting, lock-timeout handling, and retry failure states. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
Progressive migration can get stuck because emitting flag is not reverting back on error.
What is the new behavior?
Ensure flag is reverted on errors.
Keep tasks in memory queue until enqueue.
Add regression coverage.