Skip to content

Fix cron store backup churn#19484

Merged
Takhoffman merged 1 commit intoopenclaw:mainfrom
guirguispierre:codex/fix-cron-store-backup-churn
Mar 1, 2026
Merged

Fix cron store backup churn#19484
Takhoffman merged 1 commit intoopenclaw:mainfrom
guirguispierre:codex/fix-cron-store-backup-churn

Conversation

@guirguispierre
Copy link
Copy Markdown
Contributor

@guirguispierre guirguispierre commented Feb 17, 2026

Summary

saveCronStore in src/cron/store.ts was always writing jobs.json.bak on every save, even when the serialized cron payload was unchanged. This created unnecessary disk churn and made the backup file less useful because it was being overwritten with the latest state each write.

Root Cause

The previous save flow always:

  1. wrote a temp file,
  2. renamed it over jobs.json,
  3. copied the new jobs.json to jobs.json.bak.

That means .bak represented the newest snapshot, not the previous one, and it was rewritten on every persist tick.

Fix

  • Added a pre-write read of the current store content.
  • Added a no-op short-circuit when serialized JSON is unchanged.
  • When content changes, create jobs.json.bak from the previous on-disk jobs.json before replacing it.

This preserves meaningful backup semantics and avoids unnecessary backup rewrites.

Tests

Added/updated tests in src/cron/store.test.ts:

  • verifies no backup file is created when saving identical content twice,
  • verifies backup contains the previous store content after a changed save.

Validation

  • pnpm lint
  • pnpm build
  • pnpm test

AI Assistance

  • AI-assisted
  • Fully tested

Greptile Summary

Fixed unnecessary disk churn in cron store backup mechanism. The previous implementation always created a backup file on every save, even when the content was unchanged. Now the function reads the current file first, short-circuits if the serialized JSON is identical, and only creates jobs.json.bak from the previous jobs.json when the content actually changes. This preserves proper backup semantics (backup = previous state, not current state) and eliminates wasteful disk writes.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is well-designed with proper error handling, atomic file operations via temp files, and comprehensive test coverage. The logic correctly handles all edge cases including missing files, unchanged content, and first-time saves. The changes eliminate unnecessary disk I/O while preserving backup semantics.
  • No files require special attention

Last reviewed commit: 3dbb196

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@guirguispierre guirguispierre changed the title [codex] fix cron store backup churn Fix cron store backup churn Feb 17, 2026
@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Feb 28, 2026
@Takhoffman Takhoffman force-pushed the codex/fix-cron-store-backup-churn branch from 9ca5e19 to 7bb9ff8 Compare March 1, 2026 13:10
Copilot AI review requested due to automatic review settings March 1, 2026 13:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@Takhoffman Takhoffman merged commit 5784963 into openclaw:main Mar 1, 2026
9 checks passed
hwb96 pushed a commit to hwb96/openclaw that referenced this pull request Mar 1, 2026
github-actions bot pushed a commit to tankerwng2/openclaw that referenced this pull request Mar 1, 2026
zooqueen added a commit to hanzoai/bot that referenced this pull request Mar 1, 2026
ansh pushed a commit to vibecode/openclaw that referenced this pull request Mar 2, 2026
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
safzanpirani pushed a commit to safzanpirani/clawdbot that referenced this pull request Mar 2, 2026
steipete pushed a commit to Sid-Qin/openclaw that referenced this pull request Mar 2, 2026
robertchang-ga pushed a commit to robertchang-ga/openclaw that referenced this pull request Mar 2, 2026
hanqizheng pushed a commit to hanqizheng/openclaw that referenced this pull request Mar 2, 2026
execute008 pushed a commit to execute008/openclaw that referenced this pull request Mar 2, 2026
dorgonman pushed a commit to kanohorizonia/openclaw that referenced this pull request Mar 3, 2026
sachinkundu pushed a commit to sachinkundu/openclaw that referenced this pull request Mar 6, 2026
zooqueen added a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
Mateljan1 pushed a commit to Mateljan1/openclaw that referenced this pull request Mar 7, 2026
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 16, 2026
alexey-pelykh added a commit to remoteclaw/remoteclaw that referenced this pull request Mar 16, 2026
(cherry picked from commit 5784963)

Co-authored-by: Pierre <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants