Repository navigation
fix(cron): release queued reservations when activation fails - #141008
Conversation
|
🦞👀 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 14, 2026, 11:20 PM ET / September 15, 2026, 03:20 UTC (Revision 6). ClawSweeper reviewWhat this changesRelease a scheduled job’s queued reservation when admission or activation fails, add cleanup and scheduler regression coverage, and make a model-policy integration test await command completion. Merge readiness✅ Ready for maintainer review This remains a useful, bounded repair absent from current main and the latest release. No blocking patch defect was found, and the supplied runtime evidence supports the narrowed cleanup claim without establishing a fix for the related missing-tick report. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s cron scheduler reserves due jobs before admitting them for execution. Reservation cleanup settles their execution receipts and clears scheduling markers so subsequent runs can proceed. flowchart TD
A[Due scheduled job] --> B[Durable queued reservation]
B --> C[Admission and activation]
C -->|Success| D[Execute job]
C -->|Failure| E[Identity-checked cleanup]
E --> F[Settle receipt and clear marker]
F --> A
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -2, Tests +379. Total +377 across 4 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep failure cleanup with the reservation producer, preserve identity fencing and caller safety nets, and investigate receipt-free missing ticks separately. Do we have a high-confidence way to reproduce the issue? Yes, for the narrow producer defect: reject the queued-to-running write and inspect reservation state before caller cleanup. Current main retains the faulty guard; this review did not execute that reproduction. Is this the best way to solve the issue? Yes. Extending the existing identity-checked cleanup to pre-activation failures repairs the owning boundary without adding a competing recovery mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5b1d6e02a0f8. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
A transient store failure between the durable queued marker and run activation left the job holding its own queuedAtMs marker, an open receipt, and a process-local reservation. Every later tick skipped the job behind that marker, so cron-expression runs went silent until restart (openclaw#139215). Release the reservation from the producer on any admission or queued-phase failure: the receipt settles as skipped, the marker clears, and the next tick re-queues and runs the job. Recovery semantics are unchanged.
8e50f97 to
ecfe687
Compare
Preserve holny's PR openclaw#141008 producer repair and qualify activation and admission failures, replacement ownership, and scheduler siblings. Keep receipt-free missing ticks in openclaw#139215 outside this claim.
|
Merged via squash.
|
…w#141008) * fix(cron): release queued reservations when activation fails A transient store failure between the durable queued marker and run activation left the job holding its own queuedAtMs marker, an open receipt, and a process-local reservation. Every later tick skipped the job behind that marker, so cron-expression runs went silent until restart (openclaw#139215). Release the reservation from the producer on any admission or queued-phase failure: the receipt settles as skipped, the marker clears, and the next tick re-queues and runs the job. Recovery semantics are unchanged. * test(cron): qualify exact queued-reservation cleanup Preserve holny's PR openclaw#141008 producer repair and qualify activation and admission failures, replacement ownership, and scheduler siblings. Keep receipt-free missing ticks in openclaw#139215 outside this claim. * test(gateway): await model reset command completion --------- Co-authored-by: Jason (Json) <[email protected]>
* commit 'd8e50a38fd1c4df6dd69bcbc155697c464e1be45': (23 commits) fix(cron): release queued reservations when activation fails (#141008) fix(gateway): reduce CPU work in session lists and searches (#148713) feat(gateway): add admin CPU profile diagnostics (#148004) fix(gateway): cap device-required probe cache to prevent unbounded growth (#147708) fix(ci): align Gateway E2E expectations (#148653) refactor(ai): remove unused overflow wrapper (#148719) feat: stage selected chat text as editable comments (#148649) fix(ci): admit reachable release refs with large histories (#148161) fix(agents): allow authorized email CLI actions (#148521) improve(agents): trim large tool results with less CPU (#148718) refactor(docker): share image version parsing (#148243) fix(ci): retain passing hosted checks after skipped duplicates (#148722) fix(update): report configuration failures during repair (#144819) refactor(imessage): share handle classification (#148229) fix(ui): keep the selected agent across Settings pages (#148667) test(telegram): reuse deferred fixture helper (#148501) fix(media): resize images before understanding (#122431) fix: preserve unfinished work during completed PR cleanup (#148704) refactor(migrate-hermes): reuse canonical config record coercion (#148645) perf(channels): reduce history worker metadata footprint (#148711) ...
Reuse the landed test correction from openclaw#141008 so the assertion observes the completed reset before requesting history. Co-authored-by: holny <[email protected]>
Refs #139215 — kept open. After a closer pass through the timer-scheduler callers, the producer-side cleanup alone does not demonstrate the reported missing-tick fix, so this PR should not auto-close the issue.
What Problem This Solves
When the write that moves a cron run from queued to running fails, the job can be left holding a durable
queuedAtMsmarker, an open run receipt, and a process-local reservation. Three facts from the current code:executeQueuedCronRunonly released its own reservation when the failure happened after activation (if (activated)in the.catch).persistQueuedCronRunReservationsskips jobs whosequeuedAtMsis already set, so a surviving marker blocks later re-queuing.The timer scheduler does have a batch-level safety net: a mapper-level catch stops admitting further due jobs, and the batch tail calls
releaseUnclaimedDueJobReservationsWithRetry→cleanupQueuedCronRunReservations, which settles the receipt asskipped, deletesqueuedAtMs, and recomputesnextRunAtMs. So on the normal timer path a queued-phase failure self-heals at the end of that batch. The marker survives only where that batch-tail cleanup itself fails (store still erroring through the tail) or on callers without the net.That residual window does not, by itself, demonstrate the reporter's observed shape (missed occurrences with no receipt at all, manual force-runs succeeding), so this PR is a producer-side hardening, not a proven fix for every reported occurrence.
Why This Change Was Made
The queued producer owns the reservation it receives, so its failure path should release that exact reservation rather than defer to the caller's net. Any admission or queued-phase failure now runs the same
cleanupQueuedCronRunReservationsthe post-activation path already used: the receipt settles asskipped, the marker clears, and the next tick re-queues and runs the job. The cleanup is identity-matched, so it stays a no-op once another claimant has taken over. The batch-level nets in the timer scheduler and startup catch-up are unchanged.The earlier approach on this branch (proving own-process liveness inside
repairInDatabase) is fully reverted — recovery semantics are unchanged.User Impact
Jobs that fail during admission or the queued phase settle immediately instead of waiting on the batch tail; the residual wedge window shrinks to store failures that also defeat the batch-tail cleanup. No schema, config, or API changes.
Evidence
Current qualification, 2026-09-15.
Original production repair by @holny; maintainer qualification preserves its ancestry and identity-matched cleanup. No unrelated timing blocks or recovery changes were imported.
Five focused regression designs
Real local runtime trace
A separate isolated process used the candidate source, Node 24.20.0 on macOS, real SQLite, the production wall-clock timer and
runCronCommandJob. No Vitest, fake timers, product monkeypatching, model call or operator Gateway was involved. A temporary SQLite trigger injected only the selected queued-to-running write failure; it was removed before the timer was armed.The child wrote its completion artifact and exited successfully through the production command runner. This demonstrates immediate producer cleanup followed by real scheduled command execution. It does not claim real model/provider execution, full-Gateway startup or reproduction of the receipt-free missing ticks in #139215.
Maintained checks and review
1d1e62d098c1795057a274465e1d09aefa0c9ff7, with unchanged tested/reviewed source bytes.oxfmt, targetedoxlint, core production and test type checks, native schema, dependency pins/patches, boundary/coercion/deprecation/import checks, and maintained dead-export scans passed.check:changedstopped at the pre-existing datedsdk-untrusted-context-identifier-aliasesremoval guard (removeAfter: 2026-09-08). Current main marks that unrelated SDK itemremoval-pending. All 18 subsequent checks from the maintained plan were run separately and passed; no guard was disabled and no unrelated SDK policy was copied into this PR.CI repair continuation — 2026-09-15
c016b10d3754a2c0caba421b199593ce37094250. Integrated main7bf5deb308ed73fd3b327752eb6cc1b2907128b1by ordinary merge; holny’s original commit and all three cron patch payloads are preserved.expect.pollwith the existingagent.waitterminal result, requiring success before asserting the same history model. No production behavior, timeout, or test count changed.check:changedpassed in full, including the Gateway test-type graph, dead-export scans and targeted lint. New exact-head hosted CI is pending. Native preparation/merge remain gated on required CI and the independently owned trusted non-force cleanup route.