From 13e895cac0e6b5fa17fa74c963f7f5c6dcd8242c Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 29 Jun 2020 20:56:39 -0700 Subject: [PATCH] jobd/gc.sh: compute newdeltas setting after make_repack_dir In order to prepare for checking the "repack" "signature" hash, move the computation of the `$newdeltas` setting to after the call to `make_repack_dir`. This is necessary because during the computation of the `$newdeltas` setting, in certain circumstances, "mini" maintenance gets performed. That "mini" maintenance could potentially disturb the current set of packs in the repository. However, if we are potentially in a `$skipgc` situation and the final "repack" "signature" hash matches, then we will abort gc early with nothing to do and we need to be able to do that before any "mini" maintenance takes place while at the same time the check cannot be done until after `make_repack_dir` has been run. Signed-off-by: Kyle J. McKay --- jobd/gc.sh | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/jobd/gc.sh b/jobd/gc.sh index 9a40675..568fa59 100755 --- a/jobd/gc.sh +++ b/jobd/gc.sh @@ -913,31 +913,6 @@ fi progress "+ [$proj] garbage check ($(date))" -newdeltas= -[ -z "$alwaysredelta" ] || newdeltas="$noreusedeltaopt" -if [ -z "$newdeltas" ] && [ -n "$gfi_mirror" ]; then - if [ $(list_packs --exclude-no-idx --count objects/pack) -le \ - $(list_packs --exclude-no-idx --count --quiet --only gfi-packs) ]; then - # Don't bother with repack_gfi_packs since everything's being repacked - newdeltas="--no-reuse-delta" - fi -fi -if [ -z "$newdeltas" ] && [ -n "$noreusedeltaopt" ] && - [ $(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 -if [ -z "$newdeltas" ]; then - # Since we're not going to recompute deltas overall, we need to do the - # "mini" maintenance so that we can get more optimal deltas - [ -z "$noreusedeltaopt" ] || make_needs_pack - repack_gfi_packs - force_single_pack_redelta= - [ -n "$gfi_mirror" ] || [ -n "$svn_mirror" ] || force_single_pack_redelta=1 - [ -z "$noreusedeltaopt" ] || combine_small_packs $force_single_pack_redelta - [ -z "$noreusedeltaopt" ] || combine_small_loose_packs $force_single_pack_redelta -fi - # ## Safe Pruning In Forks ## @@ -1255,6 +1230,31 @@ fi ! [ -d rr-cache ] || eval git rerere gc "${quiet:+>/dev/null 2>&1}" || : make_repack_dir + +newdeltas= +[ -z "$alwaysredelta" ] || newdeltas="$noreusedeltaopt" +if [ -z "$newdeltas" ] && [ -n "$gfi_mirror" ]; then + if [ $(list_packs --exclude-no-idx --count objects/pack) -le \ + $(list_packs --exclude-no-idx --count --quiet --only gfi-packs) ]; then + # Don't bother with repack_gfi_packs since everything's being repacked + newdeltas="--no-reuse-delta" + fi +fi +if [ -z "$newdeltas" ] && [ -n "$noreusedeltaopt" ] && + [ $(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 +if [ -z "$newdeltas" ]; then + # Since we're not going to recompute deltas overall, we need to do the + # "mini" maintenance so that we can get more optimal deltas + [ -z "$noreusedeltaopt" ] || make_needs_pack + repack_gfi_packs + force_single_pack_redelta= + [ -n "$gfi_mirror" ] || [ -n "$svn_mirror" ] || force_single_pack_redelta=1 + [ -z "$noreusedeltaopt" ] || combine_small_packs $force_single_pack_redelta + [ -z "$noreusedeltaopt" ] || combine_small_loose_packs $force_single_pack_redelta +fi ! [ -e .gc_failed ] || exit 1 rm -f .gc_in_progress # make sure touch .gc_in_progress # it's truly fresh -- 2.11.4.GIT