fix: reconcile interrupted schedule executions - #6780
fix: reconcile interrupted schedule executions#6780BillLeoutsakosvl346 wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryHigh Risk Overview The schedule tick adds recovery for stale processing, claimed-pending, and unreconciled terminal carriers, with claim-guarded Stale execution cleanup terminalizes both Reviewed by Cursor Bugbot for commit c7a839a. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c7a839a. Configure here.
Greptile SummaryThis PR changes schedule outage recovery to reconcile already-claimed carriers from persisted workflow execution logs instead of redispatching them.
Confidence Score: 5/5The PR appears safe to merge; no concrete blocking or independently actionable non-blocking defect remains. Claimed carriers are reconciled without redispatch, database settlement and schedule accounting are transactionally coordinated, claim guards prevent stale occurrences from advancing newer schedule state, and cleanup predicates preserve carriers until reconciliation completes.
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/schedules/execute/route.ts | Introduces log-backed carrier reconciliation, occurrence-guarded accounting, ambiguous-enqueue preservation, and distinct handling for untouched versus claimed database jobs. |
| apps/sim/background/schedule-execution.ts | Extracts reusable claim-guarded success and cancellation accounting helpers used by normal execution and recovery. |
| apps/sim/app/api/cron/cleanup-stale-executions/route.ts | Assigns schedule carriers to schedule-specific recovery, retains unreconciled terminal carriers, and terminalizes stale redaction logs. |
| apps/sim/app/api/schedules/execute/route.test.ts | Adds broad coverage for recovered outcomes, cancellation, released and newer claims, malformed carriers, ambiguous queue operations, and at-most-once execution. |
| apps/sim/app/api/cron/cleanup-stale-executions/route.test.ts | Verifies redacting-log cleanup and schedule-carrier ownership and retention predicates. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
Tick[Schedule cron tick] --> Claim[Claim due schedule occurrence]
Claim --> Lookup[Look up deterministic carrier]
Lookup -->|No carrier| Enqueue[Create and enqueue execution carrier]
Lookup -->|Untouched pending, attempts = 0| Execute[Execute database fallback job]
Lookup -->|Claimed or terminal carrier| Evidence[Read persisted workflow execution log]
Evidence --> Classify{Classify outcome}
Classify -->|Completed / paused| Success[Apply guarded success accounting]
Classify -->|Cancelled| Cancel[Apply guarded cancellation accounting]
Classify -->|Failed / indeterminate| Failure[Apply guarded failure accounting]
Success --> Mark[Mark carrier reconciled]
Cancel --> Mark
Failure --> Mark
Mark --> Cleanup[Retention cleanup may delete carrier]
Enqueue -->|Acceptance uncertain| Preserve[Preserve occurrence claim for later reconciliation]
Reviews (1): Last reviewed commit: "simplify schedule recovery provider hand..." | Re-trigger Greptile

Summary
Reconcile claimed schedule jobs after outages from persisted workflow execution logs instead of redispatching them. Untouched database jobs still execute only while pending with zero attempts, while claimed jobs are resolved as success, failure, cancellation, pause, or an indeterminate failure. Schedule accounting uses the existing occurrence claim guard, and cleanup leaves active schedule carriers to schedule recovery.
This intentionally keeps database and Trigger.dev recovery independent. Switching queue providers while schedule jobs are outstanding remains unsupported; deployments must drain outstanding schedule jobs before changing providers.
No schema migration, public API change, or new module is introduced.
Type of Change
Testing
Reviewer focus: at-most-once behavior after a carrier is claimed, claim-guarded schedule accounting, cancellation handling, and cleanup ownership.
Checklist
Screenshots/Videos
Not applicable; server-side recovery change.