From: Gregory Szorc <gregory.szorc@gmail.com>
To: git@vger.kernel.org, stolee@gmail.com
Subject: Race condition between repack and loose-objects maintenance task
Date: Wed, 29 Jun 2022 09:55:54 -0700 [thread overview]
Message-ID: <CAKQoGamCrRMqtzziuzi8mL6E7uA3SC1WXiMGT_4rpbk1jcu_OQ@mail.gmail.com> (raw)
`git repack -A` (such as invoked by `git gc`) loosens unreachable
objects from packfiles.
`git maintenance`'s `loose-objects` task consolidates loose objects
into a packfile.
As neither process takes a lock or is otherwise aware of the existence
of the other, there is a race condition:
1. `git repack -A` creates loose objects
2. `git maintenance`'s `loose-objects` task deletes those loose objects
3. `git repack -A` fails to find the loose objects it just created and
aborts with `fatal: unable to add recent objects`
I see this failure with regularity in a custom environment where high
mutation volume repositories invoke `git maintenance run` with
regularity (effectively in reaction to repo mutations). We have a Git
housekeeping strategy that frequently invokes `git maintenance` with
all but the `gc` task. On a ~daily frequency, we invoke `git gc` to
purge accumulated garbage. This `git gc` frequently fails due to the
aforementioned race condition since the long wall time of `git gc`
practically guarantees a `git maintenance` would have been triggered
since the repo is mutated with such high frequency.
In my scenario, I believe we have a workaround by omitting
`--task=loose-objects` from the frequent `git maintenance` invocation
if there exists a `gc.pid` file. However, this is only a partial
solution, as `git repack` and the `loose-objects` task aren't aware of
each other. (I suppose running the `gc` maintenance task and relying
on the maintenance lock file could also work. However, we're invoking
`git gc` explicitly since `git maintenance` doesn't allow passing
custom arguments through to `git gc`.)
Gregory
next reply other threads:[~2022-06-29 16:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-29 16:55 Gregory Szorc [this message]
2022-06-29 17:03 ` Race condition between repack and loose-objects maintenance task Taylor Blau
2022-06-29 17:10 ` Taylor Blau
2022-06-29 17:16 ` Gregory Szorc
2022-06-29 17:21 ` Taylor Blau
2022-06-30 0:44 ` Gregory Szorc
2022-06-30 3:19 ` Taylor Blau
2022-06-30 3:23 ` Taylor Blau
2022-06-30 20:12 ` Junio C Hamano
2022-07-05 18:43 ` Gregory Szorc
2022-07-06 8:50 ` Ævar Arnfjörð Bjarmason
2022-07-20 1:40 ` Gregory Szorc
2022-07-20 9:52 ` Ævar Arnfjörð Bjarmason
2022-07-26 16:22 ` Gregory Szorc
2022-07-26 18:11 ` Ævar Arnfjörð Bjarmason
2022-07-20 1:41 ` Gregory Szorc
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKQoGamCrRMqtzziuzi8mL6E7uA3SC1WXiMGT_4rpbk1jcu_OQ@mail.gmail.com \
--to=gregory.szorc@gmail.com \
--cc=git@vger.kernel.org \
--cc=stolee@gmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).