Re: [PATCH] lockfile: add PID file for debugging stale locks
- From
Jeff King <peff@peff.net>
- Date
- Dec 3, 2025, 22:32 UTC
- Message-ID
- <20251203223220.GA66584@coredump.intra.peff.net>
- In-Reply-To
- <xmqqsedr5hrc.fsf@gitster.g>
On Wed, Dec 03, 2025 at 02:21:11PM -0800, Junio C Hamano wrote:
Show 13 quoted lines
> Jeff King <peff@peff.net> writes: > > > So I dunno what that means for your patch. I notice that the user has to > > enable the feature manually. But it feels more like it should be > > selective based on which subsystem is using the lockfile (so refs would > > never want it, but other lockfiles/tempfiles might). > > Or perhaps the way to opt into the feature is to create an empty > file $GIT_DIR/lockfile-audit, and the lockfile subsystem will append > to it every time a lock is taken? We need to ensure that a PID and > pathname formatted into a single record is small enough and O_APPEND > would relieve us from worrying about multi writer races, which may > introduce different kind of complications, though.
I like a single log much better from a management perspective. I agree that atomicity is a potential issue, though. I think that even if we kept it small, network filesystems like NFS do not provide great guarantees for atomic appends. Something like flock() can work there, but that's not something we've relied on before.
It also raises questions about reading (do we find pid files in the log in order to provide more directed advice?) and maintenance (do we ever clean it up, or just let it grow without bound?).
-Peff