Repository navigation
Description
Version: 2026.6.5
Summary:
After upgrading to 2026.6.5, a cron job that had its schedule updated via the cron.update API was triggered at the wrong time on gateway restart — based on the old schedule stored in a legacy JSON file, not the updated SQLite record.
Steps to reproduce:
- Have a cron job previously migrated from legacy JSON store to SQLite (
.migratedfile remains on disk as migration artifact) - Update the job's schedule via the
cron.updateAPI (e.g.,18 15 10 * *→18 15 11 * *) - Confirm the update is reflected in SQLite (
cron_jobstable shows new schedule, updatednext_run_at_ms) - Upgrade gateway to v2026.6.5 → gateway restarts, doctor preflight runs
- Doctor preflight reads the legacy
jobs.json.migratedfile which still contains the OLD schedule - Migration overwrites (or re-evaluates based on) the old schedule in SQLite
- Cron engine on startup detects the job as "missed" (old schedule date has already passed) and fires it immediately after a 120s deferral
Log evidence from /tmp/openclaw/openclaw-YYYY-MM-DD.log:
cron: staggering missed jobs to prevent gateway overload { totalMissed: 1 }
cron: deferring missed agent jobs until after gateway startup { count: 1, delayMs: 120000 }
The legacy JSON file had the old schedule; the SQLite had the new one. The doctor migration picked the stale version.
Root cause:
The doctor preflight cron migration reads from legacy JSON stores without checking whether the corresponding SQLite record already has newer data (e.g., by comparing cron_jobs.updated_at against the JSON file's mtime, or checking if the SQLite record exists at all for a given job ID).
Suggested fix:
- Before migrating a job from a legacy JSON store, check if the job ID already exists in the
cron_jobsSQLite table - If it exists and
cron_jobs.updated_at > source_file.mtime, skip the migration for that job - Or alternatively: treat
.migratedfiles as truly done and never re-read them during doctor preflight
Impact:
For users who have updated cron schedules via the API after the initial JSON→SQLite migration, upgrading to 2026.6.5 can cause cron jobs to fire unexpectedly at the wrong time based on stale schedule data. This is particularly dangerous for scheduled outbound messaging jobs.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 10, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 3:01 PM ET / 19:01 UTC.
Summary
Keep open: current main and v2026.6.9 still lack a scheduler-owned activation boundary for cron restart catch-up, and the live closing PR at #92398 is still open and conflicting rather than merged.
Reproducibility: yes. Current main is source-reproducible: cron.update moves nextRunAtMs without recording schedule activation, and restart catch-up replays a previous cron slot solely because it is newer than lastRunAtMs.
Root-cause cluster
Relationship:
canonicalCanonical: #91944
Summary: This issue is the canonical report for the API-updated cron schedule restart replay bug; the active closing PR is the candidate fix and older unmerged attempts are superseded.
Members:
fixed_by_candidate: fix(cron): bound restart catch-up to schedule activation #92398 - The PR body uses closing syntax for this issue and adds the schedule activation boundary plus doctor migration for the reported restart replay behavior.superseded: fix(cron): skip startup catch-up slots that predate schedule updates #92305 - The competing dedicated-field PR was closed unmerged in favor of the active PR after the legacy upgrade gap was discussed.superseded: Fix stale cron catch-up after schedule updates #92250 - This was an earlier unmerged attempt for the same stale cron catch-up behavior and was replaced by later implementations.superseded: Fix stale cron catch-up after schedule updates #92277 - This was another earlier unmerged attempt for the same stale cron catch-up behavior and was replaced by later implementations.partial_overlap: Crons ejecutaron mensajes de WhatsApp a la 1 AM fuera de horario y no se podían detener #65774 - That report also involves scheduled outbound messages firing at the wrong time, but includes broader WhatsApp stop/delete and emergency-control behavior outside this issue’s schedule-update restart replay root cause.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
A live closing PR already owns the implementation path, so ClawSweeper should not create another fix PR for this issue.
Review details
Best possible solution:
Review and land #92398, or replace it with an equivalent scheduler-owned activation boundary plus doctor migration that preserves the same upgrade behavior.
Do we have a high-confidence way to reproduce the issue?
Yes. Current main is source-reproducible: cron.update moves nextRunAtMs without recording schedule activation, and restart catch-up replays a previous cron slot solely because it is newer than lastRunAtMs.
Is this the best way to solve the issue?
Yes, with maintainer acceptance required. The linked PR’s scheduler-owned activation boundary plus doctor backfill is the best current fix shape I found, but it changes persisted cron state and conservative upgrade replay behavior.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against edd1d3319cce.
Label changes
Label changes:
clawsweeper:fix-shape-clear: Current issue advisory state selects this label.clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.Label justifications:
P1: The issue describes a real user-facing cron regression that can send scheduled outbound work at the wrong time after a schedule update and restart.impact:message-loss: The reported cron job was scheduled outbound messaging, and the bug controls whether a message job is sent, skipped, or deferred after restart.impact:session-state: The affected behavior is persisted cron scheduler state drifting from the schedule last selected through the API.Evidence reviewed
Acceptance criteria:
What I checked:
AGENTS.md:1, edd1d3319cce)VISION.md:12, edd1d3319cce)src/cron/service/timer.ts:1495, edd1d3319cce)src/cron/service/ops.ts:542, edd1d3319cce)src/cron/types.ts:283, edd1d3319cce)src/cron/service/timer.ts:1512, c645ec4555c0)Likely related people:
src/cron/service/timer.ts,src/cron/service.restart-catchup.test.ts)src/cron/service/timer.ts,src/cron/service.restart-catchup.test.ts,src/cron/store.ts)src/cron/service/timer.ts,src/cron/service/ops.ts,src/commands/doctor/cron/schedule-activation-migration.ts)src/cron/service/timer.ts,src/cron/service/ops.ts,packages/gateway-protocol/src/schema/cron.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.suifatt7799-oss commentedon Jun 10, 2026
Additional evidence from the reporter, sanitized for privacy:
Timeline (all times local, UTC+8)
cron.updateAPI call: changed schedule from18 15 10 * *→18 15 11 * *(same tz). Response confirmednextRunAtMsadvanced by exactly 86400000ms (1 day).openclaw updateto v2026.6.5. Gateway receives SIGTERM, shuts down.Key log entries (from
/tmp/openclaw/openclaw-YYYY-MM-DD.log)The critical entries appear during the second startup at ~20:33:
Additional observations
sqlite3query). ThenextRunAtMshad been correctly advanced by the API update.jobs.jsonexists in the cron directory — only.migratedarchives and run logs. The cron engine startup log referencesstorePath: ".../cron/jobs.json"but that file is absent.isolatedagentTurnwithtimeoutSeconds: 900, delivery via Telegram announce.Mitigation applied
The reporter has a state-file mechanism that prevents duplicate execution within the same month, so the unintended run caused no data loss. The job's schedule remains correct in SQLite and will skip all items on the next legitimate trigger.
Happy to provide any additional sanitized data that would help narrow this down.
fix(cron): resolve lint and type errors in openclaw#91944 test and pr…
fix(cron): resolve type narrowing issue in openclaw#91944 test
fix(cron): remove unnecessary type assertions in test
fix(cron): replace remaining state.store?.jobs?.find with storeJobs()
1 remaining item
fix(cron): stop replaying missed slots that predate the last definiti…
fix(cron): bound restart catch-up to the active schedule
fix(cron): stop replaying old schedule slots after a cron job is edit…
fix(cron): stop replaying old schedule slots after a cron job is edit…