write chunkindex fragment(s) before the archive pointer - #10248
Merged
ThomasWaldmann merged 1 commit intoAug 29, 2026
Merged
Conversation
…ckup#10239 The archive pointer write (archives/<archive_id>) is the commit point of a backup. Previously, the chunkindex fragment covering the session's new chunks was only written at cache close (and every 600s during the backup), i.e. AFTER the pointer: a crash in between left a committed archive whose chunks were partly not covered by index/*, so reads (which are routed through the index) raised ObjectNotFound until "borg check" rebuilt the index. Now Archive.save() and Archive.set_meta() (rename/tag/copy) persist the index fragment(s) covering everything the session stored so far before writing the pointer, so a committed archive always has complete index coverage. A crash before the pointer write merely leaves an index fragment referencing uncommitted objects, which is harmless (compact/rebuild prunes it). This also covers import-tar, recreate and transfer, which commit archives through Archive.save(). The close-time write is now usually a no-op (no new chunks), but is kept for sessions that store chunks without committing an archive. Also: remove the packs.rst TODO about this and update the write-order steps to match the implementation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10248 +/- ##
=======================================
Coverage 87.47% 87.47%
=======================================
Files 103 103
Lines 18534 18538 +4
Branches 2843 2843
=======================================
+ Hits 16213 16217 +4
Misses 1623 1623
Partials 698 698 ☔ View full report in Codecov by Harness. |
Member
Author
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.
Fixes #10239.
The archive pointer write (
archives/<archive_id>) is the commit point of a backup. Previously, the chunkindex fragment covering the session's new chunks was only written at cache close (and every 600s during the backup), i.e. after the pointer: a crash in between left a committed archive whose chunks were partly not covered byindex/*, so reads (which are routed through the index) raisedObjectNotFounduntilborg checkrebuilt the index.Now
Archive.save()andArchive.set_meta()(rename/tag/copy) persist the index fragment(s) covering everything the session stored so far before writing the pointer, so a committed archive always has complete index coverage. A crash before the pointer write merely leaves an index fragment referencing uncommitted objects, which is harmless (compact/rebuild prunes it). This also coversimport-tar,recreateandtransfer, which commit archives throughArchive.save(); thecheck --repairpaths already rebuild the whole index infinish().Notes:
borg transfer) write one fragment per committed archive, covering the chunks stored since the previous write; the bounded repack at cache close consolidates small fragments as before.index/*only. It fails on master: there, the archive is not even findable, as its metadata chunk cannot be read through the index.🤖 Generated with Claude Code