Repository navigation
fix(cron): keep future jobs running after startup catch-up fails - #159086
Conversation
Co-authored-by: yetval <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 3:16 PM ET / 19:16 UTC (Revision 3). ClawSweeper reviewWhat this changesCron startup arms future scheduling after catch-up fails, and the lazy Gateway cron wrapper resumes it after suspension; a SQLite-backed regression test covers the flow. Merge readiness✅ Ready for maintainer review Keep open. Current main still skips timer arming when startup catch-up rejects. The proposed repair addresses that path, and the exact-head published-updater run answers the previous review’s compatibility request. I found no blocking patch defect. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway starts the cron service, which catches up overdue jobs from its SQLite-backed store and arms a timer for future jobs. The lazy Gateway wrapper controls startup and suspension around that service. flowchart LR
A[Gateway startup] --> B[Lazy cron wrapper]
B --> C[Overdue job catch-up]
C --> D{Catch-up result}
D --> E[Report startup error]
D --> F[Arm future timer]
F --> G[Deliver scheduled jobs]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +9, Tests +110. Total +119 across 3 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: A failed catch-up should remain visible while the cron service keeps future jobs scheduled and can resume them after Gateway suspension. Do we have a high-confidence way to reproduce the issue? Yes. The related report gives a real CronService and SQLite-trigger reproduction, and current-main source still has the catch-up-before-arm ordering; this read-only review did not rerun it. Is this the best way to solve the issue? Yes. The patch repairs the cron lifecycle owner and its Gateway suspension wrapper without adding a competing scheduler, configuration option, or stored-data format. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cafb3a4d1ca2. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles) |
|
@clawsweeper re-review. Published-updater compatibility is now verified at the unchanged head by Package Acceptance run 36262657810: [email protected] to candidate, retained cron jobs/history, Gateway readiness and clean Doctor. The body explicitly separates this upgrade cell from the real CronService/Gateway-proxy fault-recovery proof. |
|
🦞👀 I queued a lightweight read-only assist pass. It will post a separate answer comment and will not edit the durable ClawSweeper review comment or trigger close, merge, repair, label, or branch changes. Request: re-review. Published-updater compatibility is now verified at the unchanged head by Package Acceptance run 36262657810: [email protected] to candidate, retained cron jobs/history, Gateway readiness and clean Doctor. The body explicitly separates this upgrade cell from the real CronService/Gateway-proxy fault-recovery proof. |
|
ClawSweeper assist: The unchanged head now has published-updater compatibility evidence, but the upgrade cell used disabled jobs, so it does not show scheduled delivery after the update. A full correctness re-review is needed. Evidence:
Suggested next action: Request the full re-review with Source: #159086 (comment) |
|
Landed in 0f5c39b. Startup catch-up errors remain reported while future cron jobs stay scheduled, including after suspension. Real SQLite-trigger before/after proof showed the later job firing once after the fault cleared; 62 focused tests, exact-head CI, and the published 2026.9.4 updater with retained cron state passed. Thanks @yetval for reporting #158969 and the original investigation and repair proposal in #144144. |
…nclaw#159086) Closes openclaw#158969. Related: openclaw#144144. ## What Problem This Solves Fixes future cron jobs never firing after a startup catch-up job encounters a transient store write failure. ## User Impact Once the write fault clears, future scheduled jobs can run without restarting the Gateway or editing a job. The startup failure remains visible. No configuration, schema, or default changes. ## Why This Change Was Made The startup lifecycle owner now arms scheduling when catch-up rejects, then rethrows the original failure, reporting any secondary arming error separately. Failed-start scheduling stays resumable through Gateway suspension; the lazy proxy delegates readiness to the service after any start attempt. Existing stop, pause, and lifecycle-generation fences remain in force. Normal startup ordering is unchanged; existing run-recovery logic settles the completed catch-up job without replaying it. ## Evidence - Real `CronService.start()` with SQLite persistence: a trigger rejects the overdue job's terminal write, startup rejects, and the trigger is removed before a later job becomes due. On the baseline the later event never arrives; with the fix both jobs deliver exactly once. The normal-start control passes on both versions. - Wall-clock candidate probe: overdue event at 1536 ms, startup rejects with `injected terminal write failure`, fault removed, upcoming event at 12018 ms; delivered events are exactly `["overdue", "upcoming"]`. - Focused startup/suspension, lazy Gateway, interval firing, and batch-finalization suites: 62 tests passed. The new three-case regression took 1.38 seconds of test time. Normal startup, terminal-write failure, and a second arming failure all deliver each event once after pause/resume. The suspension regression failed on the first candidate before the lifecycle repair. - Scoped Oxlint and touched-file TypeScript language-server diagnostics passed. - Fresh `pnpm build` passed; an isolated Gateway boot reached ready on a non-default loopback port. Full Gateway fault injection was not proven: a preinstalled trigger was correctly rejected by schema admission, and a post-admission preload did not reach the worker-owned write. The discriminating failure/recovery proof above uses the real CronService entry point, not a complete faulted Gateway boot. - Final wall-clock suspension probe: startup reports the injected write error, the fault is removed, scheduling is paused/resumed, and the future event arrives at 12026 ms without replaying the overdue event. - [Required CI](https://github.com/openclaw/openclaw/actions/runs/36262060415) passed at `3fef502f8eae6604bbc19a398a91e6a8da917bec` with no reruns. The three new regression cases took 1.211 seconds total in the hosted cron shard. ### Published-updater compatibility [Package Acceptance run 36262657810](https://github.com/openclaw/openclaw/actions/runs/36262657810) passed the existing `published-upgrade-survivor` / `legacy-operator-state` cell: published `[email protected]` updated to the candidate built from `3fef502f8eae6604bbc19a398a91e6a8da917bec` (tarball SHA-256 `8b82f19f0bb40525dd512691d12c0bbf71ef1df8c371323fe271e466a973b57f`). It retained two CLI-authored cron jobs and their history, verified the original owners after migration, and passed Gateway startup, health, readiness, status, and clean Doctor checks. A second update was already-current with no package mutations or repair. This cell proves upgrade compatibility with retained cron state. Its jobs are deliberately disabled; it does not inject the startup write fault or prove later scheduled delivery. Faulted-startup/future-fire behavior is proved separately by the real CronService wall-clock runs and the real CronService plus Gateway-proxy regression above. The existing published-driver upgrade harness has no startup write-fault injection hook. Co-authored-by: yetval <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #158969. Related: #144144.
What Problem This Solves
Fixes future cron jobs never firing after a startup catch-up job encounters a transient store write failure.
User Impact
Once the write fault clears, future scheduled jobs can run without restarting the Gateway or editing a job. The startup failure remains visible. No configuration, schema, or default changes.
Why This Change Was Made
The startup lifecycle owner now arms scheduling when catch-up rejects, then rethrows the original failure, reporting any secondary arming error separately. Failed-start scheduling stays resumable through Gateway suspension; the lazy proxy delegates readiness to the service after any start attempt. Existing stop, pause, and lifecycle-generation fences remain in force. Normal startup ordering is unchanged; existing run-recovery logic settles the completed catch-up job without replaying it.
Evidence
CronService.start()with SQLite persistence: a trigger rejects the overdue job's terminal write, startup rejects, and the trigger is removed before a later job becomes due. On the baseline the later event never arrives; with the fix both jobs deliver exactly once. The normal-start control passes on both versions.injected terminal write failure, fault removed, upcoming event at 12018 ms; delivered events are exactly["overdue", "upcoming"].pnpm buildpassed; an isolated Gateway boot reached ready on a non-default loopback port. Full Gateway fault injection was not proven: a preinstalled trigger was correctly rejected by schema admission, and a post-admission preload did not reach the worker-owned write. The discriminating failure/recovery proof above uses the real CronService entry point, not a complete faulted Gateway boot.3fef502f8eae6604bbc19a398a91e6a8da917becwith no reruns. The three new regression cases took 1.211 seconds total in the hosted cron shard.Published-updater compatibility
Package Acceptance run 36262657810 passed the existing
published-upgrade-survivor/legacy-operator-statecell: published[email protected]updated to the candidate built from3fef502f8eae6604bbc19a398a91e6a8da917bec(tarball SHA-2568b82f19f0bb40525dd512691d12c0bbf71ef1df8c371323fe271e466a973b57f). It retained two CLI-authored cron jobs and their history, verified the original owners after migration, and passed Gateway startup, health, readiness, status, and clean Doctor checks. A second update was already-current with no package mutations or repair.This cell proves upgrade compatibility with retained cron state. Its jobs are deliberately disabled; it does not inject the startup write fault or prove later scheduled delivery. Faulted-startup/future-fire behavior is proved separately by the real CronService wall-clock runs and the real CronService plus Gateway-proxy regression above. The existing published-driver upgrade harness has no startup write-fault injection hook.