cache: sentinel to invalidate the chunk index during fragment deletion#9908
Open
mr-raj12 wants to merge 3 commits into
Open
cache: sentinel to invalidate the chunk index during fragment deletion#9908mr-raj12 wants to merge 3 commits into
mr-raj12 wants to merge 3 commits into
Conversation
…ex fragments (borgbackup#9904) An interrupted fragment deletion could leave a subset that build_chunkindex_from_repo trusts as a complete index; the sentinel now forces a rebuild from packs instead.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9908 +/- ##
==========================================
+ Coverage 85.13% 85.27% +0.14%
==========================================
Files 93 93
Lines 15899 15932 +33
Branches 2428 2435 +7
==========================================
+ Hits 13535 13586 +51
+ Misses 1654 1636 -18
Partials 710 710 ☔ View full report in Codecov by Harness. |
ThomasWaldmann
requested changes
Jul 14, 2026
ThomasWaldmann
left a comment
Member
There was a problem hiding this comment.
in a future PR, we will also need to refactor these functions into a class dealing with index management.
…pace Store the marker as config/chunkindex-invalid instead of an all-zeros index/ fragment name, so it can never collide with a real fragment; detect it via a config listing.
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.
What
Deleting chunk index fragments is not crash safe: if the delete is interrupted partway, the leftover fragments look like a complete index and borg trusts them, so the index ends up missing entries or keeping stale ones.
This writes an "index invalid" marker before the first fragment delete and removes it after the last. While the marker is present, the index is rebuilt from packs on next load.
The marker lives out of band as a
config/chunkindex-invalidobject, not in theindex/namespace, so it can never collide with a realindex/<sha256>fragment. Its presence is detected with aconfig/listing, which bypasses the store cache.The marker only guards non-superset rewrites (full replacements and the invalidate-all path). Repack does not need it, since the fragments it writes already contain the entries it deletes.
Closes #9904