From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Phillip Wood <phillip.wood123@gmail.com>,
phillip.wood@dunelm.org.uk, James Liu <james@jamesliu.io>
Subject: Re: [PATCH v2 5/7] builtin/gc: add a `--detach` flag
Date: Fri, 16 Aug 2024 10:06:48 +0200 [thread overview]
Message-ID: <Zr8ImP6knHO6-ZBb@tanuki> (raw)
In-Reply-To: <xmqqttflqv27.fsf@gitster.g>
On Thu, Aug 15, 2024 at 03:29:20PM -0700, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
> > Patrick Steinhardt <ps@pks.im> writes:
> >
> >> +test_expect_success '--detach overrides gc.autoDetach=false' '
> >> + test_when_finished "rm -rf repo" &&
> >> + git init repo &&
> >> + (
> >> + cd repo &&
> >> +
> >> + # Prepare the repository such that git-gc(1) ends up repacking.
> >> + test_commit "$(test_oid blob17_1)" &&
> >> + test_commit "$(test_oid blob17_2)" &&
> >> + git config gc.autodetach false &&
> >> + git config gc.auto 2 &&
> >> +
> >> + cat >expect <<-EOF &&
> >> + Auto packing the repository in background for optimum performance.
> >> + See "git help gc" for manual housekeeping.
> >> + EOF
> >> + GIT_PROGRESS_DELAY=0 git gc --auto --detach 2>actual &&
> >> + test_cmp expect actual
> >> + )
> >> +'
> >
> > If the gc/maintenance is going to background itself, it is possible
> > that it still is running, possibly with files under repo/.git/ open
> > and the process running in repo directory, when the test_when_finished
> > clean-up trap goes in effect?
> >
> > I am wondering where this comes from:
> >
> > https://github.com/git/git/actions/runs/10408467351/job/28825980833#step:6:2000
> >
> > where "rm -rf repo" dies with an unusual
> >
> > rm: can't remove 'repo/.git': Directory not empty
> >
> > and my theory is that after "rm -rf" _thinks_ it removed everything
> > underneath, before it attempts to rmdir("repo/.git"), the repack
> > process in the background has created a new pack, and "rm -rf" does
> > not go back and try to create such a new cruft.
> >
> > The most robust way to work around such a "race" is to wait for the
> > backgrounded process before cleaning up, or after seeing that the
> > message we use as a signal that the "gc" has backgrounded itself,
> > kill that backgrounded process before exiting the test and causing
> > the clean-up to trigger.
>
> There already is a clue left by those who worked on this test the
> last time at the end of the script. It says:
>
> # DO NOT leave a detached auto gc process running near the end of the
> # test script: it can run long enough in the background to racily
> # interfere with the cleanup in 'test_done'.
>
> immediately before "test_done".
>
> In the meantime, I am wondering something simple and silly like the
> attached is sufficient. The idea is that we expect the "oops we
> couldn't clean" code not to trigger most of the time, but if it
> does, we just wait (with back off) a bit and retry.
Ah, indeed, that is a problem. We already have a better tool to fix this
with `run_and_wait_for_auto_gc()`. It creates a separate file descriptor
and waits for it to close via some shell trickery, which will only
happen once the child process of git-gc(1) has exited.
Will fix, thanks!
Patrick
next prev parent reply other threads:[~2024-08-16 8:06 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 7:17 [PATCH 0/7] builtin/maintenance: fix auto-detach with non-standard tasks Patrick Steinhardt
2024-08-13 7:17 ` [PATCH 1/7] config: fix constness of out parameter for `git_config_get_expiry()` Patrick Steinhardt
2024-08-13 7:17 ` [PATCH 2/7] builtin/gc: refactor to read config into structure Patrick Steinhardt
2024-08-15 5:24 ` James Liu
2024-08-15 8:18 ` Patrick Steinhardt
2024-08-15 13:46 ` Derrick Stolee
2024-08-13 7:17 ` [PATCH 3/7] builtin/gc: fix leaking config values Patrick Steinhardt
2024-08-15 5:22 ` James Liu
2024-08-15 8:18 ` Patrick Steinhardt
2024-08-15 13:50 ` Derrick Stolee
2024-08-13 7:17 ` [PATCH 4/7] builtin/gc: stop processing log file on signal Patrick Steinhardt
2024-08-15 6:01 ` James Liu
2024-08-13 7:17 ` [PATCH 5/7] builtin/gc: add a `--detach` flag Patrick Steinhardt
2024-08-13 7:17 ` [PATCH 6/7] builtin/maintenance: " Patrick Steinhardt
2024-08-13 7:18 ` [PATCH 7/7] builtin/maintenance: fix auto-detach with non-standard tasks Patrick Steinhardt
2024-08-13 11:29 ` Phillip Wood
2024-08-13 11:59 ` Patrick Steinhardt
2024-08-13 13:19 ` Phillip Wood
2024-08-14 4:15 ` Patrick Steinhardt
2024-08-14 15:13 ` Phillip Wood
2024-08-15 5:30 ` Patrick Steinhardt
2024-08-15 6:40 ` James Liu
2024-08-15 8:17 ` Patrick Steinhardt
2024-08-15 14:00 ` Derrick Stolee
2024-08-15 6:42 ` [PATCH 0/7] " James Liu
2024-08-15 9:12 ` [PATCH v2 " Patrick Steinhardt
2024-08-15 9:12 ` [PATCH v2 1/7] config: fix constness of out parameter for `git_config_get_expiry()` Patrick Steinhardt
2024-08-15 9:12 ` [PATCH v2 2/7] builtin/gc: refactor to read config into structure Patrick Steinhardt
2024-08-15 9:12 ` [PATCH v2 3/7] builtin/gc: fix leaking config values Patrick Steinhardt
2024-08-15 9:12 ` [PATCH v2 4/7] builtin/gc: stop processing log file on signal Patrick Steinhardt
2024-08-15 9:12 ` [PATCH v2 5/7] builtin/gc: add a `--detach` flag Patrick Steinhardt
2024-08-15 19:11 ` Junio C Hamano
2024-08-15 22:29 ` Junio C Hamano
2024-08-16 8:06 ` Patrick Steinhardt [this message]
2024-08-15 9:12 ` [PATCH v2 6/7] builtin/maintenance: " Patrick Steinhardt
2024-08-15 9:12 ` [PATCH v2 7/7] run-command: fix detaching when running auto maintenance Patrick Steinhardt
2024-08-15 16:13 ` Junio C Hamano
2024-08-16 8:06 ` Patrick Steinhardt
2024-08-15 14:04 ` [PATCH 0/7] builtin/maintenance: fix auto-detach with non-standard tasks Derrick Stolee
2024-08-15 15:37 ` Junio C Hamano
2024-08-16 8:06 ` Patrick Steinhardt
2024-08-16 10:44 ` [PATCH v3 " Patrick Steinhardt
2024-08-16 10:44 ` [PATCH v3 1/7] config: fix constness of out parameter for `git_config_get_expiry()` Patrick Steinhardt
2024-08-16 10:45 ` [PATCH v3 2/7] builtin/gc: refactor to read config into structure Patrick Steinhardt
2024-08-16 10:45 ` [PATCH v3 3/7] builtin/gc: fix leaking config values Patrick Steinhardt
2024-08-16 10:45 ` [PATCH v3 4/7] builtin/gc: stop processing log file on signal Patrick Steinhardt
2024-08-16 10:45 ` [PATCH v3 5/7] builtin/gc: add a `--detach` flag Patrick Steinhardt
2024-08-16 10:45 ` [PATCH v3 6/7] builtin/maintenance: " Patrick Steinhardt
2024-08-17 7:09 ` Jeff King
2024-08-17 7:14 ` Jeff King
2024-08-19 6:17 ` Patrick Steinhardt
2024-08-16 10:45 ` [PATCH v3 7/7] run-command: fix detaching when running auto maintenance Patrick Steinhardt
2024-08-17 12:14 ` Jeff King
2024-08-19 6:17 ` Patrick Steinhardt
2024-08-19 7:47 ` [PATCH 0/3] Fixups for git-maintenance(1) tests Patrick Steinhardt
2024-08-19 7:47 ` [PATCH 1/3] t7900: fix flaky test due to leaking background job Patrick Steinhardt
2024-08-19 8:49 ` Jeff King
2024-08-19 8:55 ` Patrick Steinhardt
2024-08-19 9:12 ` Jeff King
2024-08-19 9:17 ` Patrick Steinhardt
2024-08-19 7:48 ` [PATCH 2/3] t7900: exercise detaching via trace2 regions Patrick Steinhardt
2024-08-19 8:51 ` Jeff King
2024-08-19 8:56 ` Patrick Steinhardt
2024-08-21 18:38 ` Junio C Hamano
2024-08-22 5:41 ` Patrick Steinhardt
2024-08-22 17:22 ` Junio C Hamano
2024-08-19 7:48 ` [PATCH 3/3] builtin/maintenance: fix loose objects task emitting pack hash Patrick Steinhardt
2024-08-19 8:55 ` Jeff King
2024-08-19 9:07 ` Patrick Steinhardt
2024-08-19 9:17 ` Jeff King
2024-08-19 9:26 ` Patrick Steinhardt
2024-08-19 10:26 ` Jeff King
2024-08-20 7:39 ` Patrick Steinhardt
2024-08-20 15:58 ` Junio C Hamano
2024-08-19 17:05 ` Junio C Hamano
2024-08-19 8:46 ` [PATCH v3 7/7] run-command: fix detaching when running auto maintenance Jeff King
2024-08-19 9:04 ` Patrick Steinhardt
2024-08-19 10:49 ` Patrick Steinhardt
2024-08-19 15:41 ` Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zr8ImP6knHO6-ZBb@tanuki \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=james@jamesliu.io \
--cc=phillip.wood123@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).