From 350eaf81f9215751a1858e045c267cbe034b1a0c Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sat, 30 Dec 2017 15:02:16 -0800 Subject: [PATCH] gc.sh: do not always ignore non pack-<40hex>*.pack files When doing a full garbage collection (or even possibly a "mini") there exist brief moments when a pack might exist with a name not matching pack-<40hex>*.pack. This should only happen when combining packs and replacing a same-named pack and the old pack briefly takes on a "oldpack-<40hex>*.pack" name during the replace. However, there could be other *.pack files present in the repository for some unknown reason. And we need to avoild the extremely remote possibility of oldpack-*.pack files accumulating from interruptions of --replace operations anyway. Stop ignoring the other names (except for the pre-auto-gc ones) and handle them just like any other packs, mostly. They continue to be ignored by "mini" gc activity because there just shouldn't be any in the first place, but if there are then a full gc will now address them. Signed-off-by: Kyle J. McKay --- jobd/gc.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/jobd/gc.sh b/jobd/gc.sh index 7e1e0be..554721f 100755 --- a/jobd/gc.sh +++ b/jobd/gc.sh @@ -841,7 +841,7 @@ if [ -z "$newdeltas" ] && [ -n "$gfi_mirror" ]; then fi fi if [ -z "$newdeltas" ] && [ -n "$noreusedeltaopt" ] && - [ $(list_packs --exclude-no-idx --count-objects objects/pack) -le $var_redelta_threshold ]; then + [ $(list_packs --all --exclude-no-idx --count-objects objects/pack) -le $var_redelta_threshold ]; then # There aren't enough objects to worry about so just redelta to get the best pack newdeltas="--no-reuse-delta" fi @@ -1170,21 +1170,25 @@ gotforks= # We rename to insert an "_r" just before the extension to avoid "Push Pack Redux" # name collisions. Later on we may create an "unreachable" pack for hard-linking # down into forks and it will have an "_u" inserted just before its extension. -packlist="$(list_packs -C objects/pack --exclude-no-idx --exclude-keep --quiet .)" || : +packlist="$(list_packs -C objects/pack --all --exclude-no-idx --exclude-keep --quiet .)" || : oldpacks= for oldpack in $packlist; do - oldpack="${oldpack#pack-}" oldpack="${oldpack%.pack}" - [ -f "objects/pack/pack-$oldpack.pack" ] || { + [ -f "objects/pack/$oldpack.pack" ] || { echo >&2 "[$proj] unable to list old pack files" exit 1 } - if [ "${oldpack#*[!0-9a-fA-F]}" != "$oldpack" ]; then + case "$oldpack" in pre-auto-gc-[12]) + # we never disturb pre-auto-gc-1 or pre-auto-gc-2 packs + continue + esac + oldpackhex="${oldpack#pack-}" + if [ "${oldpackhex#*[!0-9a-fA-F]}" != "$oldpackhex" ]; then # names not exclusively hexadecimal do not need renaming oldpacks="${oldpacks:+$oldpacks }$oldpack" continue fi - rename_pack "objects/pack/pack-$oldpack" "objects/pack/pack-${oldpack}_r" || { + rename_pack "objects/pack/$oldpack" "objects/pack/${oldpack}_r" || { echo >&2 "[$proj] unable to rename old pack files" exit 1 } @@ -1197,8 +1201,8 @@ for oldpack in $packlist; do # If it hasn't started yet that's okay because we're done moving that # name so a complete pack will appear under the old name that we'll # leave alone. - if [ -f "objects/pack/pack-$oldpack.keep" ]; then - echo "Push Pack Redux" >"objects/pack/pack-${oldpack}_r.keep" + if [ -f "objects/pack/$oldpack.keep" ]; then + echo "Push Pack Redux" >"objects/pack/${oldpack}_r.keep" else oldpacks="${oldpacks:+$oldpacks }${oldpack}_r" fi @@ -1388,7 +1392,7 @@ done # shrinks it down to just the time after the find but before the following rm >repack/oldpacks [ -z "$oldpacks" ] || -printf 'objects/pack/pack-%s.pack\n' $oldpacks | +printf 'objects/pack/%s.pack\n' $oldpacks | LC_ALL=C sort >repack/oldpacks find -L objects/pack -maxdepth 1 -type f -name "pack-$octet20*.pack" -newer .gc_in_progress -print | LC_ALL=C sort >repack/freshened -- 2.11.4.GIT