Re: [PATCH] lockfile: add PID file for debugging stale locks
- From
Torsten Bögershausen <tboegi@web.de>
- Date
- Dec 3, 2025, 19:48 UTC
- Message-ID
- <20251203194809.GA13919@tb-raspi4>
- In-Reply-To
- <pull.2011.git.1764688047077.gitgitgadget@gmail.com>
On Tue, Dec 02, 2025 at 03:07:27PM +0000, Paulo Casaretto via GitGitGadget wrote:
Show 30 quoted lines
> From: Paulo Casaretto <pcasaretto@gmail.com> > > When a lock file is held, it can be helpful to know which process owns > it, especially when debugging stale locks left behind by crashed > processes. Add an optional feature that creates a companion .lock.pid > file alongside each lock file, containing the PID of the lock holder. > > The .lock.pid file is created when a lock is acquired (if enabled), and > automatically cleaned up when the lock is released (via commit or > rollback). The file is registered as a tempfile so it gets cleaned up > by signal and atexit handlers if the process terminates abnormally. > > When a lock conflict occurs, the code checks if the PID from the .pid > file is still running using kill(pid, 0). This allows providing > context-aware error messages. With PID info enabled: > > Lock is held by process 12345. Wait for it to finish, or remove > the lock file to continue. > > Or for a stale lock: > > Lock was held by process 12345, which is no longer running. > Remove the stale lock file to continue. > > Without PID info (default): > > Another git process seems to be running in this repository. > Wait for it to finish, or remove the lock file to continue. > > The feature is opt-in via GIT_LOCK_PID_INFO=1 environment variable.
[]
I think that this makes sense. However, as a frequent user of Git repos hosted on an NFS server (without any problems in my setup):
Does it make sense to add the hostname here ? We already have xgethostname() in Git, so that we can diagnose who/which machine really left a lock.
[]