summaryrefslogtreecommitdiff
path: root/t/t2071-restore-patch.sh
diff options
context:
space:
mode:
authorLibravatar Taylor Blau <me@ttaylorr.com>2020-11-25 12:17:33 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-11-25 13:15:56 -0800
commit506ec2fbda5334c4fc60fbd9f425fff3916a2066 (patch)
tree5d19a27848fddb8ee93489e81e676fb0af465f8f /t/t2071-restore-patch.sh
parentpackfile.c: protect against disappearing indexes (diff)
downloadtgif-506ec2fbda5334c4fc60fbd9f425fff3916a2066.tar.xz
midx.c: protect against disappearing packs
When a packed object is stored in a multi-pack index, but that pack has racily gone away, the MIDX code simply calls die(), when it could be returning an error to the caller, which would in turn lead to re-scanning the pack directory. A pack can racily disappear, for example, due to a simultaneous 'git repack -ad', You can also reproduce this with two terminals, where one is running: git init while true; do git commit -q --allow-empty -m foo git repack -ad git multi-pack-index write done (in effect, constantly writing new MIDXs), and the other is running: obj=$(git rev-parse HEAD) while true; do echo $obj | git cat-file --batch-check='%(objectsize:disk)' || break done That will sometimes hit the error preparing packfile from multi-pack-index message, which this patch fixes. Right now, that path to discovering a missing pack looks something like 'find_pack_entry()' calling 'fill_midx_entry()' and eventually making its way to call 'nth_midxed_pack_entry()'. 'nth_midxed_pack_entry()' already checks 'is_pack_valid()' and propagates an error if the pack is invalid. So, this works if the pack has gone away between calling 'prepare_midx_pack()' and before calling 'is_pack_valid()', but not if it disappears before then. Catch the case where the pack has already disappeared before 'prepare_midx_pack()' by returning an error in that case, too. Co-authored-by: Jeff King <peff@peff.net> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2071-restore-patch.sh')
0 files changed, 0 insertions, 0 deletions