Repository navigation
fix(cron): a cron config change no longer aborts running cron jobs - #197606
Conversation
…ent scheduler A scheduling-only cron reload stopped the old scheduler through the shutdown drain, which aborted every in-flight cron run and recorded it as an error. The handover now stops the old owner without aborting its runs, and the replacement's startup recovery leaves jobs still running in this process to that live run. Fixes #197591. Reported by @wupingyuan81-oss.
|
🦞👀 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. What this changesPreserve running cron jobs and their result delivery when cron configuration reloads on the same store. Example: Run a 60-second cron command and set cron.skipMissedJobs=true after 15 seconds.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current automation failure and resolves both prior findings; no actionable introduced defect remains. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway config reload replaces the cron scheduler; existing launch contexts retain execution and receipt settlement while the replacement schedules future work. flowchart TD
A[Configuration change] --> B[Gateway cron replacement]
B --> C[Old scheduler handover]
C --> D[Existing runs finish]
B --> E[Worker startup recovery]
E --> F[Preserve live receipts]
D --> G[Record and deliver results]
F --> G
Technical reviewBest possible solution: Land the focused handover repair with existing workers retaining receipt settlement and genuine shutdown retaining cancellation. Do we have a high-confidence way to reproduce the issue? Current-main source establishes reload → predecessor drain → active-run abort, corroborated by the reporter’s timeline and the contributor’s before/after Gateway output; no target code was executed during this review. Is this the best way to solve the issue? The patch addresses cancellation at its lifecycle owner, reuses existing launch contexts, and preserves worker-owned settlement without adding a competing execution path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 02ec944de426. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +44, Tests -1. Total +43 across 11 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed November 12, 2026, 5:09 AM ET / 10:09 UTC (Revision 3). |
|
Proof on a built Gateway in secretless Docker (node:24.22.1).
Setup:
On the candidate, 10 s after the reload the job is still running with no error. Each slot has exactly one record, so there's no duplicate run after the handover. Controls
Shutdown timing is the same on both. With a command run in progress, the cron run drain hits its 10 s wait on main and on the candidate alike (main runs 2 and 3, candidate runs 1 to 3). One main run finished in 84 ms. Tests in the same container:
Production code is +20/−5 across |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…un results Recovery now protects the exact receipts a same-store owner in this process still holds, including a timed-out run's execution settlement, instead of jobs with an active marker. A scheduler retired by a reload handover still publishes the finished events of runs that were already executing.
|
Proof for head Setup is the same as the earlier proof, with one change: the job now posts its result to a local webhook (
On the candidate, 10 s after the reload the job is still running with no error. Each slot has one record and one webhook, so there's no duplicate run or delivery after the handover. Controls (same head)
Shutdown looks the same on main and the candidate. SIGTERM is logged at the action, and the spawn-broker close step fails about 17 s later in all three restart runs. Changes since the last proof:
Tests in the same container at this head: Production code is +65/−21 across 10 files. Test lines are net −1. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in ce76ed2. Thanks @wupingyuan81-oss for the report. |
…load A cron config change hands scheduling to a replacement and lets runs already executing finish (openclaw#197606). A fired condition waiting for a run slot ended instead: its wait followed the scheduler scope, which the handover aborts, so the run was recorded as aborted without its payload. - The wait ends when the run is aborted or the scheduler stops, but not when it is handed over. A stop wakes waiters so they see it. - Slot waiters on a store wake on any owner's queue turn, and while a handed-over owner has waiters, a store wake also drains the live scheduler owners, so the replacement hands the waiting payload a slot. Refs openclaw#196859
…197340) * fix(cron): queue condition checks instead of backing them off A condition check that found all three evaluations busy was turned away and retried on the 30s-to-5min admission backoff, even when a slot freed at once, and a quiet (fire: false) success left the waiting episode and its retry count in place. - The run queue admits at most three runs that are still evaluating a condition. Further checks stay queued in due-time order with no running marker, so they hold no run slot, spend no run budget and keep their occurrence across a restart. The evaluator's own cap and its busy result are gone. - A fired condition stops counting as a check, so the next one starts while the payload runs. - A quiet check ends the waiting episode, like a payload run does. - While any job has a condition, scheduled runs without one leave one run slot free. - A queued timed occurrence survives a graceful shutdown: the host drain no longer activates timed work while the Gateway drains, service stop leaves it in the durable queue, and an activated launch the stopping host refuses is released for the next process instead of skipped. Refs #196859 * fix(cron): keep checks running while a job waits for its conversation A job that runs inside the conversation that created it waits for that conversation to be idle before it starts. The queue activated it first, so the wait held a run slot and, for a watcher, one of the three condition checks: three watchers behind one long turn stopped every other check until the turn ended. - The host tells the queue which jobs continue a conversation that is busy. Their timed occurrences stay queued, the way runs whose agent is still preparing do, and the host drains again when the conversation goes idle. A waiting occurrence therefore shows as queued, not running, and a schedule change cancels it like any queued run. - Requested and event runs keep their activation before the wait, and a turn that starts between the drain and the launch is still waited out at launch. - Scheduled runs without a condition can use all eight run slots; the slot held back for checks is removed. Refs #196859 * refactor(cron): drop the unused busy trigger evaluation flag The evaluator no longer returns a busy result, so nothing sets triggerEval.busy. Remove the field, its three readers and the tests that set it by hand. * fix(cron): keep condition checks off the run slots A condition check took one of the eight run slots before it started, so eight long runs stopped every check until one of them ended. - A timed check counts against the three-check limit only. A run counts against the eight run slots once its condition fires. - A fired condition then waits, holding neither a check nor a slot, for the queue drain to hand it one. The drain gives freed slots to waiting payloads and queued runs in due-time order, so a run due before the check still starts first. The payload runs on the result of that one check. The wait pauses the run's time budget, grants nothing while scheduling is paused or the Gateway drains, checks active hours again, and ends without a payload if the service stops. A failed request for the slot is retried each time the queue moves. - Requested checks and the checks of script-payload jobs take a run slot at activation as before: a script payload's budget cannot pause. Refs #196859 * fix(cron): keep a fired condition's slot wait across a cron config reload A cron config change hands scheduling to a replacement and lets runs already executing finish (#197606). A fired condition waiting for a run slot ended instead: its wait followed the scheduler scope, which the handover aborts, so the run was recorded as aborted without its payload. - The wait ends when the run is aborted or the scheduler stops, but not when it is handed over. A stop wakes waiters so they see it. - Slot waiters on a store wake on any owner's queue turn, and while a handed-over owner has waiters, a store wake also drains the live scheduler owners, so the replacement hands the waiting payload a slot. Refs #196859
…penclaw#197606) fix(cron): keep running cron jobs alive across a cron config reload Changing any cron config key, for example with openclaw config set cron.skipMissedJobs true, hot-reloaded with restartCron, which retired the old scheduler through the shutdown drain and aborted in-flight cron runs, recording them as interrupted by a Gateway restart although the Gateway never stopped. A scheduling-only cron reload now hands over to the new scheduler through CronService.handOver(): runs already executing finish once, their results and delivery are still published, and the delivery fence treats the handover generation as live rather than as a stop. Startup recovery leaves receipts held by a live owner or a handed-over owner alone, so a settling run is not closed and retried, while receipts of a really stopped owner are still recovered. A real Gateway stop or restart still aborts running jobs. No text changes. Evidence: a built Gateway with a two-minute command job that runs 60 s and posts to a completion webhook. On main, the reload aborted the running job after about 16 s with no webhook, in each run. With this change the running job finishes once with ok and is delivered, the webhook arrives one second after it ends, and the next slot runs once with no duplicate. A reload followed by a restart still aborts the handed-over run at the stop, a plain restart aborts the same way on both, and a non-cron reload leaves the run untouched. Tests are -1 net. Details: openclaw#197606 (comment). Fixes openclaw#197591. Thanks @wupingyuan81-oss for the report. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#197340) * fix(cron): queue condition checks instead of backing them off A condition check that found all three evaluations busy was turned away and retried on the 30s-to-5min admission backoff, even when a slot freed at once, and a quiet (fire: false) success left the waiting episode and its retry count in place. - The run queue admits at most three runs that are still evaluating a condition. Further checks stay queued in due-time order with no running marker, so they hold no run slot, spend no run budget and keep their occurrence across a restart. The evaluator's own cap and its busy result are gone. - A fired condition stops counting as a check, so the next one starts while the payload runs. - A quiet check ends the waiting episode, like a payload run does. - While any job has a condition, scheduled runs without one leave one run slot free. - A queued timed occurrence survives a graceful shutdown: the host drain no longer activates timed work while the Gateway drains, service stop leaves it in the durable queue, and an activated launch the stopping host refuses is released for the next process instead of skipped. Refs openclaw#196859 * fix(cron): keep checks running while a job waits for its conversation A job that runs inside the conversation that created it waits for that conversation to be idle before it starts. The queue activated it first, so the wait held a run slot and, for a watcher, one of the three condition checks: three watchers behind one long turn stopped every other check until the turn ended. - The host tells the queue which jobs continue a conversation that is busy. Their timed occurrences stay queued, the way runs whose agent is still preparing do, and the host drains again when the conversation goes idle. A waiting occurrence therefore shows as queued, not running, and a schedule change cancels it like any queued run. - Requested and event runs keep their activation before the wait, and a turn that starts between the drain and the launch is still waited out at launch. - Scheduled runs without a condition can use all eight run slots; the slot held back for checks is removed. Refs openclaw#196859 * refactor(cron): drop the unused busy trigger evaluation flag The evaluator no longer returns a busy result, so nothing sets triggerEval.busy. Remove the field, its three readers and the tests that set it by hand. * fix(cron): keep condition checks off the run slots A condition check took one of the eight run slots before it started, so eight long runs stopped every check until one of them ended. - A timed check counts against the three-check limit only. A run counts against the eight run slots once its condition fires. - A fired condition then waits, holding neither a check nor a slot, for the queue drain to hand it one. The drain gives freed slots to waiting payloads and queued runs in due-time order, so a run due before the check still starts first. The payload runs on the result of that one check. The wait pauses the run's time budget, grants nothing while scheduling is paused or the Gateway drains, checks active hours again, and ends without a payload if the service stops. A failed request for the slot is retried each time the queue moves. - Requested checks and the checks of script-payload jobs take a run slot at activation as before: a script payload's budget cannot pause. Refs openclaw#196859 * fix(cron): keep a fired condition's slot wait across a cron config reload A cron config change hands scheduling to a replacement and lets runs already executing finish (openclaw#197606). A fired condition waiting for a run slot ended instead: its wait followed the scheduler scope, which the handover aborts, so the run was recorded as aborted without its payload. - The wait ends when the run is aborted or the scheduler stops, but not when it is handed over. A stop wakes waiters so they see it. - Slot waiters on a store wake on any owner's queue turn, and while a handed-over owner has waiters, a store wake also drains the live scheduler owners, so the replacement hands the waiting payload a slot. Refs openclaw#196859
…197606) fix(cron): keep running cron jobs alive across a cron config reload Changing any cron config key, for example with openclaw config set cron.skipMissedJobs true, hot-reloaded with restartCron, which retired the old scheduler through the shutdown drain and aborted in-flight cron runs, recording them as interrupted by a Gateway restart although the Gateway never stopped. A scheduling-only cron reload now hands over to the new scheduler through CronService.handOver(): runs already executing finish once, their results and delivery are still published, and the delivery fence treats the handover generation as live rather than as a stop. Startup recovery leaves receipts held by a live owner or a handed-over owner alone, so a settling run is not closed and retried, while receipts of a really stopped owner are still recovered. A real Gateway stop or restart still aborts running jobs. No text changes. Evidence: a built Gateway with a two-minute command job that runs 60 s and posts to a completion webhook. On main, the reload aborted the running job after about 16 s with no webhook, in each run. With this change the running job finishes once with ok and is delivered, the webhook arrives one second after it ends, and the next slot runs once with no duplicate. A reload followed by a restart still aborts the handed-over run at the stop, a plain restart aborts the same way on both, and a non-cron reload leaves the run untouched. Tests are -1 net. Details: #197606 (comment). Fixes #197591. Thanks @wupingyuan81-oss for the report. Co-authored-by: Ayaan Zaidi <[email protected]> Backport: retain the release system-job reconciler and store revision APIs. Handover joins that reconciler and stream teardown without invoking the Gateway-wide execution abort drain. Preserve shutdown behavior and protect live receipts during replacement startup. Add the focused handover regression in a separate file to preserve the test-file size limit. (cherry picked from commit ce76ed2) Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> (cherry picked from commit 8a9710ed5503592a6dbcee3fb13ab8ca2a2c6d9d)
Preserve the existing 2026.11.5 beta line and its pending test repairs. Repair transcript admission, terminal SQLite iterators, binary attachment classification, detached lifecycle calls, cron late wakes and reload handover. Carry the explicitly requested Bonjour package-integrity fix and release guidance. Selected backports: #188055, #198309, #190242, #198860, #198011, #197658, #197484, #197606. #198011 is the operator-required open PR head, not a merged-main claim. Cron tests are adapted to the existing beta runtime. (cherry picked from commit e3064bf) (cherry picked from commit afa871c) (cherry picked from commit 2c0ab86) (cherry picked from commit fee19a9) (cherry picked from commit dbb6f39) (cherry picked from commit 4d9f782) (cherry picked from commit 87c10f5) (cherry picked from commit ce76ed2) Proof: frozen parent suite passed all 7 shards (265 tests) in 274.45s. Separate unchanged-production baseline reproduced transcript/lifecycle, late-wake and live-receipt failures. SQLite already passed on Node 26.12.1. Independent review found no actionable P0/P1 defects in this snapshot. The complete beta.4 candidate and stable-profile FRV remain pending. Co-authored-by: jalehman <[email protected]> Co-authored-by: vincentkoc <[email protected]> Co-authored-by: Yun. <[email protected]> Co-authored-by: ava-perry <[email protected]> Co-authored-by: Alfred J Berchtold <[email protected]> Co-authored-by: Stronggenetics <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Fixes #197591. Thanks @wupingyuan81-oss for the report and timeline.
What Problem This Solves
Changing a cron setting while the Gateway is running, for example with
openclaw config set cron.skipMissedJobs true, hot-reloads cron. The reload retired the old scheduler through the shutdown drain, which aborts every cron run in progress. A run that was working normally was cut off and recorded as an error ("job interrupted by gateway restart"), even though the Gateway never stopped.Why This Change Was Made
When cron stays enabled on the same store, a cron reload already hands its exit watchers to the replacement scheduler. Runs that are already executing are now handed over the same way:
server-cron.ts,CronService.handOver): the handover stops scheduling and stream watchers without the shutdown drain, so it no longer aborts active cron runs. A scheduler retired this way still publishes the finished events of runs that were already executing: broadcasts, hooks, completion webhooks and announce delivery. Its delivery fence (delivery-attempt-fence.ts) accepts the handover, so the primary webhook or announce of such a run still goes out. A real stop still suppresses all of this, as before.run-recovery): it used to treat every receipt still marked running as abandoned. It now leaves the receipts that a same-store owner in this process still holds (its launch contexts) and will settle to that owner: a live owner, or one a reload handed over. That covers a timed-out run whose execution is still settling, so the timeout fencing from fix(cron): prevent overlapping retries after execution timeouts #189469 still holds. An owner stopped for real discards its results, so recovery still closes its receipts as before.Unchanged:
Evidence
run-recovery.test.tsadds two cases: recovery leaves a running receipt its owner still holds alone, and keeps a timed-out run's receipt until its execution settles. Both then recover as before once released. With this test file onmain, the live-receipt cases fail.run-recovery,service.restart-delivery,timer,timer.regression,timer.timeout-watchdog,service.cross-tick-admission,server-cron,server-cron-lazyandserver-reload-hot.cron-lazy.oxlintis clean.