Skip to content

cache: sentinel to invalidate the chunk index during fragment deletion#9908

Draft
mr-raj12 wants to merge 1 commit into
borgbackup:masterfrom
mr-raj12:fix-9904-chunkindex-invalidated-sentinel
Draft

cache: sentinel to invalidate the chunk index during fragment deletion#9908
mr-raj12 wants to merge 1 commit into
borgbackup:masterfrom
mr-raj12:fix-9904-chunkindex-invalidated-sentinel

Conversation

@mr-raj12

Copy link
Copy Markdown
Contributor

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 invalidated" sentinel before the first fragment delete and removes it after the last. While the sentinel is present, the index is rebuilt from packs.

The sentinel 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

…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

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.09091% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.25%. Comparing base (7da670c) to head (913eb3e).
⚠️ Report is 5 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/borg/cache.py 90.00% 2 Missing and 2 partials ⚠️
src/borg/repository.py 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9908      +/-   ##
==========================================
+ Coverage   85.13%   85.25%   +0.12%     
==========================================
  Files          93       93              
  Lines       15899    15936      +37     
  Branches     2428     2436       +8     
==========================================
+ Hits        13535    13587      +52     
+ Misses       1654     1638      -16     
- Partials      710      711       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

borg2: partial index delete problematic

1 participant