From: Jun Wu <quark.zju@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, gitster@pobox.com, ps@pks.im,
Jun Wu <quark@meta.com>
Subject: Re: [PATCH 2/2] commit: lock index before reading
Date: Wed, 14 Oct 2026 17:19:37 -0700 [thread overview]
Message-ID: <20261015001938.2092523-1-quark.zju@gmail.com> (raw)
In-Reply-To: <20261014100432.GB1344504@coredump.intra.peff.net>
Hi Peff,
On Wed, 14 Oct 2026 06:04:32 -0400, Jeff King wrote:
> I do think your patch fixes the problem. But we probably want to discuss
> that in the commit message as a motivation (and likewise, discuss the
> fact that we may be holding the lock for longer).
Will do in v2: describe the race as motivation, and mention the longer hold
trade-off.
I'd like to note 'commit' is just one command with the read/lock order issue.
There are many others, like: reset, rebase, stash, am, merge, etc.
Some are easy to fix, some seem tricky (e.g. merge).
Do you think that I should fix all order issues before adding the timeout?
Note Patch 1 alone does not hurt - if a command has the read/lock order issue
and is therefore racy, then the timeout feature is automatically disabled
(by the 'initialized' check) so the racy command behaves exactly the same as
before, not worse.
My plan is to add the timeout support first, then incrementally fix order
issues, starting from the easy/more common ones (e.g. commit).
> There's probably some kind of hybrid world where we optimistically read
> without the lock, then take the lock, and then check (cheaply-ish) that
> the index didn't change since what we read. But I don't think we do that
> in this code path.
For reference, 'status' is such an example, although its write is optional.
'add -i' could be another example - it avoids locking when waiting for user
input, although it lacks the "didn't change" check right now.
-Jun
next prev parent reply other threads:[~2026-10-15 0:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 17:23 [PATCH 0/2] Add a way to wait for index lock Jun Wu
2026-10-13 17:23 ` [PATCH 1/2] repository: add core.indexLockTimeout Jun Wu
2026-10-13 21:40 ` D. Ben Knoble
2026-10-14 2:38 ` Jun Wu
2026-10-14 16:29 ` D. Ben Knoble
2026-10-13 22:05 ` Junio C Hamano
2026-10-14 22:12 ` Jun Wu
2026-10-13 17:23 ` [PATCH 2/2] commit: lock index before reading Jun Wu
2026-10-14 10:04 ` Jeff King
2026-10-15 0:19 ` Jun Wu [this message]
2026-10-13 22:05 ` [PATCH 0/2] Add a way to wait for index lock Junio C Hamano
2026-10-14 22:12 ` Jun Wu
2026-10-14 10:14 ` Jeff King
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=20261015001938.2092523-1-quark.zju@gmail.com \
--to=quark.zju@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=ps@pks.im \
--cc=quark@meta.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox