repository: add replace_pack helper#9798
Merged
ThomasWaldmann merged 4 commits intoJun 22, 2026
Merged
Conversation
borgbackup#8572 borgbackup#8514 Copies the kept objects into a new pack via store.defrag, repoints their chunk index entries, and deletes the old pack; an empty keep set drops the pack whole.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9798 +/- ##
==========================================
+ Coverage 84.68% 84.77% +0.08%
==========================================
Files 92 92
Lines 15216 15251 +35
Branches 2279 2286 +7
==========================================
+ Hits 12886 12929 +43
+ Misses 1631 1622 -9
- Partials 699 700 +1 ☔ View full report in Codecov by Harness. |
Document the old_pack_id return and the caller's index-durability duty, reword the delete-old-last rationale, and test the reproduced-pack skip and survivor sort.
ThomasWaldmann
requested changes
Jun 22, 2026
Rename replace_pack to compact_pack; it now repoints kept and deletes dropped index entries, asserting keep + drop tile the whole pack. refs borgbackup#8572 borgbackup#8514
ThomasWaldmann
requested changes
Jun 22, 2026
…kept keep_ids/drop_ids are now keyword-only sets; one loop over their union replaces two; survivors renamed to kept; intersection asserted empty.
b25364e to
bf36090
Compare
Member
|
test_manifest_rebuild_corrupted_chunk is still failing frequently. |
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.
Description
Adds
Repository.replace_pack(old_pack_id, keep_ids): rewrites a pack to keep only the given objects and deletes the old one.store.defrag(runs store/server-side, so their bytes are not pulled over the network on remote repos).This is the pack-level primitive that compact, check and delete will use to remove objects once a pack holds more than one (N greater than 1). No callers are wired up yet; that follows in separate PRs.
Tests cover the copy-forward of a mixed pack (forced max_count greater than 1) and the whole-pack drop.
refs #8572 #8514
Checklist
master