compact, repo-compress: superseded duplicate dropped when its indexed copy is in a missing or corrupt pack
borg2 master (a586f6931): compact_pack and transform_pack drop a superseded duplicate (an object in a pack gap whose chunk id the index maps to another location) without checking that the indexed copy is readable. If that location is in a pack missing from the store or recorded corrupt, the dropped object can be the only intact copy of the chunk.
superseded_gap_rangesonly compares the index entry's location with the gap object's location.borg compactandborg repo-compresskeep index entries that reference a missing pack ("borg check --repair removes them") and pass that index tocompact_pack/transform_pack.- Same for an index entry pointing into a pack recorded corrupt in
cache/checked-packs.
Repro (unit level):
- Pack A holds W, X, Y. Pack B holds a second copy of X, the index maps X to B, so X in A is a gap object.
- Delete pack B from the store. W, X used, Y unused.
borg compactlogsindex entries referencing a missing pack file: 1and1 of them are still in use: repository data is missing!, then rewrites A (Y is unused) and drops X from it.repository.get(X)raisesObjectNotFound. Before the compact, X was still in A.
borg repo-compress drops it the same way: transform_pack drops superseded duplicates even if no object is recompressed.
Proposal: pass the ids of the packs missing from the store and the packs recorded corrupt to superseded_gap_ranges; an index entry pointing into one of them does not make a gap object a superseded duplicate.
Blocks #10471, which adds dropping whole packs of superseded duplicates.
Source: borgbackup/borg