fix(backup): serialize and atomically publish snapshots (salvage #69411) - #77913
Merged
kshitijk4poor merged 1 commit intoAug 3, 2026
Merged
Conversation
kshitijk4poor
enabled auto-merge (rebase)
August 3, 2026 18:13
This was referenced Aug 4, 2026
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Salvages the backup-safety commit of #69411 by @hao Wang — cherry-picked with authorship preserved.
Context — what this fixes, for whom
Anyone with automatic backups + manual snapshots:
run_backup,create_quick_snapshot, and the automatic full-zip path could run CONCURRENTLY (gateway auto-backup firing while a user runs /snapshot), interleaving SQLite safe-copies and half-written snapshot directories. The commit adds a shared cross-process backup lock (_backup_operation_lock, lockfile + BackupInProgressError) and atomic publication: snapshots build in a staging dir and rename into place, so a crashed backup can never leave a half-snapshot that restore would trust.Scope decisions (bundle split — the PR carries 4 distinct concerns)
Kept: the backup commit (f0fcaf5: 241 lines backup.py + 105-line stability test file), the concern with the clearest bug and cleanest boundary.
Adaptations:
track_activity("backup", ...)telemetry wrappers — they importhermes_cli.perf_diagnostics, a module introduced by a DIFFERENT commit of the bundle (e304e97) that isn't salvaged here. The locking (the actual fix) is fully preserved; the telemetry can ride with a future perf_diagnostics PR.Dropped for separate consideration (documented in the close comment):
Verification
tests/hermes_cli/test_backup_stability.py: 6 passed (concurrent-backup serialization, atomic publish, staging cleanup)Closes #69411 (backup core superseded by this salvage — original author credited via cherry-pick authorship; remaining concerns documented for re-proposal).