Migrations: shared queue - #2339
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 16 files
Confidence score: 5/5
- Safe to merge after the addressed issues were fixed.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 16 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Contributor
|
Capy auto-review is paused for this organization because the usage-cycle auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
Migration concurrency was partitioned by organization or migration, then multiplied again inside each run. Overlapping organization migrations could therefore saturate the primary database. This change uses Trigger.dev's existing queue and checkpoint primitives instead of adding a Redis capacity controller or database schema.
Validation
cd server && bun test --isolate tests/unit/migrations-v2— 29 passedcd server && bun tscd vite && bun test tests/views/migrations/migration/build-run-migration-request.test.ts— 2 passedcd vite && bun tsgit diff --checkRemaining live verification
Summary by cubic
Share migration fleet capacity across runs by moving customer work to a single shared
@trigger.devqueue and coordinating background runs in time-sliced chunks. The coordinator submits finite slices, yields quickly, and ignores per-run concurrency.New Features
migration-customer-workwith concurrency 1 for customer slices and lazy tasks; the coordinator runs off-queue.afterInternalId; count queries are skipped during slices to reduce overhead.Migration
concurrencyinput is accepted for compatibility but ignored; effective concurrency is 1.concurrency: 1.Written for commit 717e33b. Summary will update on new commits.
Greptile Summary
This PR moves migration work onto shared fleet capacity. The main changes are:
Confidence Score: 5/5
This looks safe to merge after confirming the new queue-state call matches the installed Trigger.dev SDK.
server/src/trigger/migrations/migrationTaskQueue.ts
Important Files Changed
Sequence Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram participant API as Migration API participant Queue as Shared Queue participant Run as Background Run participant Lazy as Lazy Customer Task participant DB as Item Tracking API->>Queue: Enqueue migration run Queue->>Run: Start run loop Customers Run->>DB: Claim and process customer Run->>Queue: Check queued work after slice alt Work is waiting Run->>Queue: Checkpoint Queue->>Lazy: Process queued customer task Lazy->>DB: Claim and migrate customer Queue->>Run: Resume run else Queue is idle Run->>Run: Continue immediately end end%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% sequenceDiagram participant API as Migration API participant Queue as Shared Queue participant Run as Background Run participant Lazy as Lazy Customer Task participant DB as Item Tracking API->>Queue: Enqueue migration run Queue->>Run: Start run loop Customers Run->>DB: Claim and process customer Run->>Queue: Check queued work after slice alt Work is waiting Run->>Queue: Checkpoint Queue->>Lazy: Process queued customer task Lazy->>DB: Claim and migrate customer Queue->>Run: Resume run else Queue is idle Run->>Run: Continue immediately end endPrompt To Fix All With AI
Reviews (1): Last reviewed commit: "feat(migrations): share fleet capacity a..." | Re-trigger Greptile
Context used (4)