Uh oh!
There was an error while loading. Please reload this page.
improvement(scheduler): raise per-tick claim budget to drain backlog - #4567
Conversation
MAX_CRON_CLAIMS 20 -> 100; reserved workflow/job slots 10/10 -> 50/50. Throughput was capped at 20 schedules/tick which created a 20+ hour backlog when due work exceeded ~1 item per cron-second.
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview This allows each cron tick of Reviewed by Cursor Bugbot for commit 4591c1b. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR addresses a chronic scheduler backlog by raising
Confidence Score: 4/5Safe to merge for the workflow-schedule path; the inline-job path deserves a quick operational check at the new concurrency level before relying on it under full load. The change touches two integer constants and leaves every lock, claim, transaction, and overflow-reallocation path intact. The only non-trivial risk is the 5x increase in concurrent inline job executions per tick — if those jobs are DB- or network-heavy, a busy tick could see noticeably more resource pressure than before, and there is no observability or back-pressure in place to catch a latency cliff. apps/sim/app/api/schedules/execute/route.ts — specifically the inline job execution block (lines 316–338) and the executeJobInline implementation it calls. Important Files Changed
Sequence DiagramsequenceDiagram
participant Cron as Cron Trigger (60s tick)
participant Handler as /api/schedules/execute
participant DB as Database (FOR UPDATE SKIP LOCKED)
participant Queue as Async Job Queue
participant Inline as executeJobInline
Cron->>Handler: GET (authenticated)
Handler->>DB: "claimWorkflowSchedules(limit=50)"
DB-->>Handler: up to 50 workflow rows (locked)
Handler->>DB: "claimJobSchedules(limit=50)"
DB-->>Handler: up to 50 job rows (locked)
Note over Handler: remainingClaimBudget = 100 - claimed
par Workflow schedules up to 50
Handler->>Queue: enqueue schedule-execution payload
Queue-->>Handler: jobId
and Mothership jobs up to 50 always inline
Handler->>Inline: executeJobInline(payload) x up to 50 concurrent
Inline-->>Handler: done
end
Handler-->>Cron: executedCount N
|
Bumps MAX_CRON_CLAIMS 100 -> 200 (workflow/job split 100/100). Pairs with the fire-and-forget cron Lambda change so per-tick processing time is no longer bounded by the Lambda's 50s HTTP timeout.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4591c1b. Configure here.
Uh oh!
There was an error while loading. Please reload this page.

Summary
MAX_CRON_CLAIMS20 → 200; reserved workflow/job slots 10/10 → 100/100.Processing 20 due itemsticks with a chronic backlog. A workflow scheduled for midnight today only fired at 11:32 UTC because that's when its row finally reached the head of the queue.Type of Change
Testing
bun run lint— cleanbun run check:api-validation:strict— passesChecklist