Thread (22 messages) 22 messages, 8 authors, 2026-02-06

Re: [PATCH v3] lockfile: add PID file for debugging stale locks

flat view

From: Patrick Steinhardt <hidden>
Date: 2026-01-05 12:23:26

On Sat, Dec 27, 2025 at 02:50:25AM -0500, Jeff King wrote:
On Wed, Dec 24, 2025 at 12:24:13PM +0000, Paulo Casaretto via GitGitGadget wrote:
quoted
For a lock file "foo.lock", the PID file is named "foo~pid.lock". The
tilde character is forbidden in refnames and allowed in Windows
filenames, which guarantees no collision with the refs namespace
(e.g., refs "foo" and "foo~pid" cannot both exist). The file uses a
simple key-value format ("pid <value>") following the same pattern as
Git object headers, making it extensible for future metadata.
FWIW, I like this approach, as the earlier collision possibilities in
earlier iterations made me a bit uncomfortable.

But then I wondered...
quoted
The feature is controlled via core.lockfilePid configuration, which
accepts per-component values similar to core.fsync:

  - none: Disable for all components (default)
  - all: Enable for all components
  - index, config, refs, commit-graph, midx, shallow, gc, other:
    Enable for specific components
Do we really need this complexity now? I can see reasons why a user
might want to switch the feature on (because they want the extra pid
debugging info) or off (because they do not want the extra filesystem
operations or potential cleanup hassle of extra stale files).

But if the collision problems in the ref namespace are now solved, does
anybody really care about turning it on just for particular subsystems?
I'd think they would want all or nothing.


Trying to devil's advocate myself: maybe somebody is concerned about
filesystem overhead for frequently-written files like refs but not for
others, like config? That feels unlikely to me, but at least possible.

But if we were to ditch the subsystem-granularity for config, then all
of the extra LOCKFILE_* arguments here could just go away.
I tend to agree. Based on my own experience, references are by far the
most likely subsystem where one may hit stale lockfiles, so the feature
is most useful there. But at the same time, it's also the most expensive
subsystem to enable this feature for because we write so many small
files there.

Consequently, if anybody cares, they would most likely want to enable
this feature for refs. And, if so, the impact on other subsystems would
very likely be dwarfed by the refs overhead.

So my approach would be to enable this setting with only "true" and
"false" as possible values initially. And if we ever get a use case
where somebody would be helped by configuring this per subsystem we can
extend the config to learn about subsystems.

But ultimately I don't care too strongly about this. If the author wants
to keep the current approach I'm fine with that, too.

Patrick
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help