git/builtin
Derrick Stolee 0af067276e builtin/repack.c: only repack .packs that exist
In 73320e49ad (builtin/repack.c: only collect fully-formed packs,
2023-06-07), we switched the check for which packs to collect by
starting at the .idx files and looking for matching .pack files. This
avoids trying to repack pack-files that have not had their pack-indexes
installed yet.

However, it does cause maintenance to halt if we find the (problematic,
but not insurmountable) case of a .idx file without a corresponding
.pack file. In an environment where packfile maintenance is a critical
function, such a hard stop is costly and requires human intervention to
resolve (by deleting the .idx file).

This was not the case before. We successfully repacked through this
scenario until the recent change to scan for .idx files.

Further, if we are actually in a case where objects are missing, we
detect this at a different point during the reachability walk.

In other cases, Git prepares its list of packfiles by scanning .idx
files and then only adds it to the packfile list if the corresponding
.pack file exists. It even does so without a warning! (See
add_packed_git() in packfile.c for details.)

This case is much less likely to occur than the failures seen before
73320e49ad. Packfiles are "installed" by writing the .pack file before
the .idx and that process can be interrupted. Packfiles _should_ be
deleted by deleting the .idx first, followed by the .pack file, but
unlink_pack_path() does not do this: it deletes the .pack _first_,
allowing a window where this process could be interrupted. We leave the
consideration of changing this order as a separate concern. Knowing that
this condition is possible from interrupted Git processes and not other
tools lends some weight that Git should be more flexible around this
scenario.

Add a check to see if the .pack file exists before adding it to the list
for repacking. This will stop a number of maintenance failures seen in
production but fixed by deleting the .idx files.

This brings us closer to the case before 73320e49ad in that 'git
repack' will not fail when there is an orphaned .idx file, at least, not
due to the way we scan for packfiles. In the case that the .pack file
was erroneously deleted without copies of its objects in other installed
packfiles, then 'git repack' will fail due to the reachable object walk.

This does resolve the case where automated repacks will no longer be
halted on this case. The tests in t7700 show both these successful
scenarios and the case of failing if the .pack was truly required.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2023-07-11 13:07:50 -07:00
..
add.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
am.c Merge branch 'cw/strbuf-cleanup' 2023-07-06 11:54:46 -07:00
annotate.c strvec: rename struct fields 2020-07-30 19:18:06 -07:00
apply.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
archive.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
bisect.c repository: remove unnecessary include of path.h 2023-06-21 13:39:53 -07:00
blame.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
branch.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
bugreport.c editor: move editor-related functions and declarations into common file 2023-04-11 08:52:10 -07:00
bundle.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
cat-file.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
check-attr.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
check-ignore.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
check-mailmap.c builtin.h: remove unneccessary includes 2023-06-21 13:39:54 -07:00
check-ref-format.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
checkout--worker.c read-cache*.h: move declarations for read-cache.c functions from cache.h 2023-06-21 13:39:53 -07:00
checkout-index.c read-cache*.h: move declarations for read-cache.c functions from cache.h 2023-06-21 13:39:53 -07:00
checkout.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
clean.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
clone.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
column.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
commit-graph.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
commit-tree.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
commit.c Merge branch 'js/empty-index-fixes' 2023-07-08 11:23:07 -07:00
config.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
count-objects.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
credential-cache--daemon.c credential: erase all matching credentials 2023-06-15 13:26:41 -07:00
credential-cache.c builtin.h: remove unneccessary includes 2023-06-21 13:39:54 -07:00
credential-store.c Merge branch 'cw/strbuf-cleanup' 2023-07-06 11:54:46 -07:00
credential.c builtins: mark unused prefix parameters 2023-03-28 14:11:24 -07:00
describe.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
diagnose.c object-file.h: move declarations for object-file.c functions from cache.h 2023-04-11 08:52:10 -07:00
diff-files.c diff.h: remove unnecessary include of oidset.h 2023-06-21 13:39:53 -07:00
diff-index.c Merge branch 'en/header-split-cache-h-part-3' 2023-06-29 16:43:21 -07:00
diff-tree.c log-tree: replace include of revision.h with simple forward declaration 2023-06-21 13:39:53 -07:00
diff.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
difftool.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
fast-export.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
fast-import.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
fetch-pack.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
fetch.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
fmt-merge-msg.c wrapper.h: move declarations for wrapper.c functions from cache.h 2023-03-21 10:56:53 -07:00
for-each-ref.c builtin.h: remove unneccessary includes 2023-06-21 13:39:54 -07:00
for-each-repo.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
fsck.c Merge branch 'jk/fsck-indices-in-worktrees' 2023-07-08 11:23:08 -07:00
fsmonitor--daemon.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
gc.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
get-tar-commit-id.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
grep.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
hash-object.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
help.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
hook.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
index-pack.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
init-db.c builtin.h: remove unneccessary includes 2023-06-21 13:39:54 -07:00
interpret-trailers.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
log.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
ls-files.c Merge branch 'rs/strbuf-expand-step' 2023-07-06 11:54:45 -07:00
ls-remote.c git-compat-util.h: remove unneccessary include of wildmatch.h 2023-06-21 13:39:54 -07:00
ls-tree.c Merge branch 'rs/strbuf-expand-step' 2023-07-06 11:54:45 -07:00
mailinfo.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
mailsplit.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
merge-base.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
merge-file.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
merge-index.c read-cache*.h: move declarations for read-cache.c functions from cache.h 2023-06-21 13:39:53 -07:00
merge-ours.c diff.h: remove unnecessary include of oidset.h 2023-06-21 13:39:53 -07:00
merge-recursive.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
merge-tree.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
merge.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
mktag.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
mktree.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
multi-pack-index.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
mv.c read-cache*.h: move declarations for read-cache.c functions from cache.h 2023-06-21 13:39:53 -07:00
name-rev.c git-compat-util.h: remove unneccessary include of wildmatch.h 2023-06-21 13:39:54 -07:00
notes.c Merge branch 'tl/notes-separator' 2023-07-06 11:54:47 -07:00
pack-objects.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
pack-redundant.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
pack-refs.c pack-refs: teach pack-refs --include option 2023-05-12 14:54:14 -07:00
patch-id.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
prune-packed.c treewide: be explicit about dependence on gettext.h 2023-03-21 10:56:51 -07:00
prune.c Merge branch 'en/header-split-cache-h-part-3' 2023-06-29 16:43:21 -07:00
pull.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
push.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
range-diff.c diff.h: remove unnecessary include of oidset.h 2023-06-21 13:39:53 -07:00
read-tree.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
rebase.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
receive-pack.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
reflog.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
remote-ext.c builtins: annotate always-empty prefix parameters 2023-03-28 14:11:24 -07:00
remote-fd.c builtins: annotate always-empty prefix parameters 2023-03-28 14:11:24 -07:00
remote.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
repack.c builtin/repack.c: only repack .packs that exist 2023-07-11 13:07:50 -07:00
replace.c Merge branch 'en/header-split-cache-h-part-3' 2023-06-29 16:43:21 -07:00
rerere.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
reset.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
rev-list.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
rev-parse.c Merge branch 'en/header-split-cache-h-part-3' 2023-06-29 16:43:21 -07:00
revert.c diff.h: remove unnecessary include of oidset.h 2023-06-21 13:39:53 -07:00
rm.c read-cache*.h: move declarations for read-cache.c functions from cache.h 2023-06-21 13:39:53 -07:00
send-pack.c config: add ctx arg to config_fn_t 2023-06-28 14:06:39 -07:00
shortlog.c diff.h: remove unnecessary include of oidset.h 2023-06-21 13:39:53 -07:00
show-branch.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
show-index.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
show-ref.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
sparse-checkout.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
stash.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
stripspace.c Merge branch 'cw/strbuf-cleanup' 2023-07-06 11:54:46 -07:00
submodule--helper.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
symbolic-ref.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
tag.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
unpack-file.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
unpack-objects.c Merge branch 'en/header-split-cache-h-part-3' 2023-06-29 16:43:21 -07:00
update-index.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
update-ref.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
update-server-info.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
upload-archive.c repository: remove unnecessary include of path.h 2023-06-21 13:39:53 -07:00
upload-pack.c Merge branch 'en/header-split-cache-h-part-3' 2023-06-29 16:43:21 -07:00
var.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
verify-commit.c object-store-ll.h: split this header out of object-store.h 2023-06-21 13:39:54 -07:00
verify-pack.c builtin.h: remove unneccessary includes 2023-06-21 13:39:54 -07:00
verify-tag.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00
worktree.c Merge branch 'gc/config-context' 2023-07-06 11:54:48 -07:00
write-tree.c cache.h: remove this no-longer-used header 2023-06-21 13:39:53 -07:00