Repository navigation
fix(cron): scheduled runs silently skipped when the scheduler wakes late with skipMissedJobs - #197484
Conversation
…with skipMissedJobs
A scheduler tick that arrives more than MIN_REFIRE_GAP_MS (2 s) after its
planned wake sets catchupNeeded and takes the catch-up path. With
cron.skipMissedJobs on, that path moves every due cron/every slot to its
next occurrence instead of running it, so on a busy host (event-loop stalls
of a few seconds) enabled jobs silently lose whole slots: no run record,
no error, no log line.
skipMissedJobs is meant for slots missed while the Gateway was down. Keep
the bounded, staggered catch-up for late ticks, but skip slots only at
startup or when wall time outran monotonic time (clock step, suspend). A
slot that came due before a merely late tick now runs.
Skips are now logged ("cron: skipped missed slots (cron.skipMissedJobs)")
with the job ids and the reason (startup or clock-jump). Only slots the
pass actually moves are listed, so a slot passed over earlier is not
reported again on every later catch-up.
|
🦞👀 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 changesThis PR runs due recurring jobs after a late scheduler wake while preserving missed-slot skipping at startup and after clock jumps. Example: With cron.skipMissedJobs enabled, a process stall delays a 05:39:00 cron slot until 05:39:03.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current scheduler bug and resolves the previous review findings; no actionable defects remain, with exact-head CI still pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe cron worker receives scheduler commands, job rows, and timing observations, selects eligible occurrences, and passes them to the existing run queue for receipt-backed execution. flowchart TD
A[Gateway scheduler] --> B[Cron worker actor]
C[Stored jobs] --> B
B --> D[Late wake or clock jump]
D --> E[Bounded catch-up]
E --> F[Existing run queue]
F --> G[Execution and run records]
Technical reviewBest possible solution: Merge the focused scheduler repair once the existing exact-head CI gates pass. Do we have a high-confidence way to reproduce the issue? Yes: the supplied built-Gateway A/B proof reproduces lost slots on main using a real process stall, and current-main source confirms the responsible catch-up branch. Is this the best way to solve the issue? The patch repairs the decision in the existing scheduler owner, reuses timing baselines, preserves bounded staggering and queue admission, and adds distinct late-wake and clock-jump regressions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3b13df5767c2. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +6, Tests -2. Total +4 across 2 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. Review metrics
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 (4 earlier review cycles)
Reviewed November 12, 2026, 1:16 AM ET / 06:16 UTC (Revision 5). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Detect a clock jump at tick time instead of tracking it on the actor, drop the new skip log, fold the regression rows into the existing catch-up table, and remove the test-line allocation.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Proof on a built Gateway (secretless Docker, node:24.22.1). I ran
"Run" is the time the job's command wrote. "Record" is the Gateway run record from
Controls:
In every candidate run, the late slot has exactly one run and one record. Focused tests in the same container: Changes on top of @Stronggenetics's fix:
Production code is +10/-4 against |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 87c10f5. Thanks @Stronggenetics. |
…ate with skipMissedJobs (openclaw#197484) fix(cron): run late slots that came due while the Gateway was up with skipMissedJobs With cron.skipMissedJobs on, the scheduler treated any wake more than 2 seconds late like downtime, so a run that came due while the Gateway was up but briefly stalled was silently skipped with no record. Clock jumps are now detected at tick time, and a late wake without a jump runs the slot once. Skipping missed slots after real downtime and across a wall-clock jump is unchanged, and nothing stored changes. No text changes. Evidence: a built Gateway in a secretless node:24.22.1 container with skipMissedJobs on and a one-minute command job, the whole Gateway process group stopped with SIGSTOP just before a slot and resumed 8 s later, two runs each. On main the stalled slot had no run and no record; with this change it runs once about 3 s late with one record. A restart after real downtime still skips the missed slot, a process-local +90 s Date step skips the slots it jumps over on both, and with the setting off the late slot runs once on both. The late-wake row in the existing catch-up table fails on main, at -2 net test lines. Details: openclaw#197484 (comment). Thanks @Stronggenetics. Co-authored-by: Ayaan Zaidi <[email protected]>
…ate with skipMissedJobs (#197484) fix(cron): run late slots that came due while the Gateway was up with skipMissedJobs With cron.skipMissedJobs on, the scheduler treated any wake more than 2 seconds late like downtime, so a run that came due while the Gateway was up but briefly stalled was silently skipped with no record. Clock jumps are now detected at tick time, and a late wake without a jump runs the slot once. Skipping missed slots after real downtime and across a wall-clock jump is unchanged, and nothing stored changes. No text changes. Evidence: a built Gateway in a secretless node:24.22.1 container with skipMissedJobs on and a one-minute command job, the whole Gateway process group stopped with SIGSTOP just before a slot and resumed 8 s later, two runs each. On main the stalled slot had no run and no record; with this change it runs once about 3 s late with one record. A restart after real downtime still skips the missed slot, a process-local +90 s Date step skips the slots it jumps over on both, and with the setting off the late slot runs once on both. The late-wake row in the existing catch-up table fails on main, at -2 net test lines. Details: #197484 (comment). Thanks @Stronggenetics. Co-authored-by: Ayaan Zaidi <[email protected]> Backport: preserve the release runtime-row mutation owner and versioned scheduler snapshots; port late-wake classification without newer cached-job or deferred-admission architecture. (cherry picked from commit 87c10f5) Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]> (cherry picked from commit b0c5872f3e6f5011cde0ba3394c39e32a743d11e)
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]>
Related: #179927 (a different silent-drop path, already closed)
What Problem This Solves
Fixes: enabled cron jobs silently lose whole runs (no run record, no error, no log line) when
cron.skipMissedJobsis on and the scheduler's timer fires more than 2 s late, which happens routinely on a busy Gateway.User Impact
User impact: with
cron.skipMissedJobs: true, a slot that comes due while the Gateway is running now runs even if the scheduler wakes late. Slots are still skipped after downtime or a clock jump, as documented. No config, schema, log or protocol change. WithskipMissedJobsoff nothing changes (late ticks already ran their slots).Why This Change Was Made
A scheduler tick that arrives more than
MIN_REFIRE_GAP_MS(2 s) after its planned wake setscatchupNeeded, exactly like a wall-clock jump, and goes throughboundedCatchup. There,skipMissedJobsmoves every duecron/everyslot to its next occurrence without running it. So an event-loop stall or a slow SQLite write was treated like downtime.The catch-up pass now skips missed slots only at startup or when the wall clock jumped (wall time outran monotonic time since the last tick). A pass that is only late still runs slots whose
nextRunAtMshas come due, bounded and staggered as before. A slot found missed only from its last run (itsnextRunAtMsis still in the future) is still advanced, as before. The jump is measured at tick time; a refresh keeps the last tick's baselines, so no extra actor state is needed.Evidence
Focused tests:
src/cron/store/scheduler-actor.worker.test.tspasses 24/24 at this head. With the same test file onmain, only the new late-wake row fails. Three rows were added to the existing catch-up table, and the run-finalization setup the file repeated is now one helper, so the file has fewer lines than onmain:skipMissedJobson)mainBuilt Gateway in Docker (proof comment): on
main, a Gateway stalled across a slot (SIGSTOP/SIGCONT) has no run for that slot, twice. At this head the slot runs once, about 3 s late, twice. Restarting after real downtime, a process-local clock step and the setting off all behave as before.Running Gateway. A Linux systemd Gateway with about 105 enabled automations,
cron.skipMissedJobs: true, on stable 2026.11.3 plus local patches. The same run/skip change was deployed there on 2026-11-11 at 12:43 ET. That build also logged an info line for each skip (cron: skipped missed slots); this head does not add that log line. Excerpts below are raw output with job names, run summaries, store paths and tokens removed; job ids are cut to 8 characters, times are ET. Run records come fromopenclaw cron runs --all --json;slotis the scheduled time encoded in each run id (cron-slot-v1.<base64url [storeKey, jobId, slotMs]>).1. With the fix: the scheduler wakes 23 s late and the due slots run (2026-11-11 19:50 ET)
Gateway log (
/tmp/openclaw/openclaw-2026-11-11.log, UTC):The three ids on the skip line are jobs whose last slot was dropped before the fix was deployed (nothing was due for them). Run records for the 19:50 slots:
On
mainthis wake (more than 2 s after the planned 19:50:00 wake) takes the same catch-up path and moves each of these jobs to its next slot unrun.2. Intentional skip diagnostics: slots missed during downtime are still skipped (restart 2026-11-11 14:26 ET)
17 jobs had a slot while the host was down; they were skipped, then resumed on their next slot. This head skips them the same way; it does not add the log line.
3. Before the fix: the same 5-minute jobs lose a slot with no trace (2026-11-11 11:35 ET, build without this change)
Gateway journal from the same minutes shows the event loop stalled (a build was running on the host from 11:09 to 11:44):
The old code logs nothing when it moves a slot, so there is no skip line to show; the detailed file log for that period was lost in a host reboot.
Whole-day comparison (every slot each cron expression should have produced vs. the run records):
After the reboot the late-tick catch-up path ran at least 80 times in 7 hours, and 64 of those passes started 152 slots that had come due more than 2 s before the wake.
Gaps: jobs that run every 5-30 s were not counted (they overlap their own previous runs by design). One 30-second slot at 21:05:30 ET did not run during a 19.6 s main-thread SQLite write; the late pass at 21:05:57 found that job's
nextRunAtMsalready past the slot, so an earlier step moved it, and its receipts were pruned before the cause could be checked. Not claimed as fixed here.