run-command: fix detaching when running auto maintenance
In the past, we used to execute `git gc --auto` as part of our automatic housekeeping routines. As git-gc(1) may require quite some time to perform the housekeeping, it knows to detach itself and run in the background so that the user can continue their work. Eventually, we refactored our automatic housekeeping to instead use the more flexible git-maintenance(1) command. The upside of this new infra is that the user can configure which maintenance tasks are performed, at least to a certain degree. So while it continues to run git-gc(1) by default, it can also be adapted to e.g. use git-multi-pack-index(1) for maintenance of the object database. The auto-detach of the new infra is somewhat broken though once the user configures non-standard tasks. The problem is essentially that we detach at the wrong level in the process hierarchy: git-maintenance(1) never detaches itself, but instead it continues to be git-gc(1) which does. When configured to only run the git-gc(1) maintenance task, then the result is basically the same as before. But when configured to run other tasks, then git-maintenance(1) will wait for these to run to completion. Even worse, it may be that git-gc(1) runs concurrently with other housekeeping tasks, stomping on each others feet. Fix this bug by asking git-gc(1) to not detach when it is being invoked via git-maintenance(1). Instead, git-maintenance(1) now respects a new config "maintenance.autoDetach", the equivalent of "gc.autoDetach", and detaches itself into the background when running as part of our auto maintenance. This should continue to behave the same for all users which use the git-gc(1) task, only. For others though, it means that we now properly perform all tasks in the background. The default behaviour of git-maintenance(1) when executed by the user does not change, it will remain in the foreground unless they pass the `--detach` option. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
a6affd3343
commit
98077d06b2
@ -40,7 +40,8 @@ use, it'll affect how the auto pack limit works.
|
||||
|
||||
gc.autoDetach::
|
||||
Make `git gc --auto` return immediately and run in the background
|
||||
if the system supports it. Default is true.
|
||||
if the system supports it. Default is true. This config variable acts
|
||||
as a fallback in case `maintenance.autoDetach` is not set.
|
||||
|
||||
gc.bigPackThreshold::
|
||||
If non-zero, all non-cruft packs larger than this limit are kept
|
||||
|
@ -3,6 +3,17 @@ maintenance.auto::
|
||||
`git maintenance run --auto` after doing their normal work. Defaults
|
||||
to true.
|
||||
|
||||
maintenance.autoDetach::
|
||||
Many Git commands trigger automatic maintenance after they have
|
||||
written data into the repository. This boolean config option
|
||||
controls whether this automatic maintenance shall happen in the
|
||||
foreground or whether the maintenance process shall detach and
|
||||
continue to run in the background.
|
||||
+
|
||||
If unset, the value of `gc.autoDetach` is used as a fallback. Defaults
|
||||
to true if both are unset, meaning that the maintenance process will
|
||||
detach.
|
||||
|
||||
maintenance.strategy::
|
||||
This string config option provides a way to specify one of a few
|
||||
recommended schedules for background maintenance. This only affects
|
||||
|
Reference in New Issue
Block a user