backup-scheduler: dont replay missed daily slots on startup #42

Merged
Matt merged 1 commits from fix/backup-scheduler-no-replay into main 2026-05-28 13:52:58 +00:00
Owner

Fixes a bug where the wrapper, on service restart, would fire one catch-up backup per minute for each daily-times slot that had already passed today. With a schedule like 00:00,04:00,08:00,12:00,16:00,20:00 and a restart at 19:00, this meant 5 near-identical full-world zips at 1-minute intervals.

Source comment already documented the intended behaviour but the code didnt implement it. Fixed in Start() by pre-populating _firedToday with all times <= now.

Tested live on glados. New binary deployed. Switched schedule to clock-aligned 00:00,04:00,08:00,12:00,16:00,20:00 after deploy: zero catch-up backups fired in the 90s window after restart (vs 5+ before the fix).

Fixes a bug where the wrapper, on service restart, would fire one catch-up backup per minute for each daily-times slot that had already passed today. With a schedule like `00:00,04:00,08:00,12:00,16:00,20:00` and a restart at 19:00, this meant 5 near-identical full-world zips at 1-minute intervals. Source comment already documented the intended behaviour but the code didnt implement it. Fixed in `Start()` by pre-populating `_firedToday` with all times <= now. Tested live on glados. New binary deployed. Switched schedule to clock-aligned `00:00,04:00,08:00,12:00,16:00,20:00` after deploy: zero catch-up backups fired in the 90s window after restart (vs 5+ before the fix).
Matt added 1 commit 2026-05-27 19:31:47 +00:00
The wake loop's daily-times branch was firing one missed slot per minute
on service restart. With a schedule like "00:00,04:00,08:00,12:00,16:00,
20:00" and a restart at 19:00, the wrapper would catch up by firing 5
backups at 1-minute intervals -- each a full-world zip of the same
in-memory world. Pure waste: the live world hasn't diverged across the
missed clock slots, the snapshots would be near-identical, and the rapid
save-off/save-on churn impacts player experience.

Source comment already documented the intended behaviour ("Doesn't catch
up if the server was off when a slot passed -- daily/interval backups
don't need replay logic.") but the code didn't implement it.

Fix: in Start(), pre-populate _firedToday with all times <= now so the
wake loop only fires future slots for the rest of today.

Tested live on glados: switched schedule to clock-aligned daily-times
after deploying the fix, zero catch-up backups fired in the 90s window
after restart (vs 5+ before the fix).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Matt merged commit a8ff660114 into main 2026-05-28 13:52:58 +00:00
Matt deleted branch fix/backup-scheduler-no-replay 2026-05-28 13:52:58 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: minecraft/brass-and-sigil#42