๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
3 messages
3 total messages Started by Steve Tue, 17 Nov 2026 17:48
User-initiated recovery for stale index.lock
#3256
Author: Steve
Date: Tue, 17 Nov 2026 17:48
9 lines
11262 bytes
Hi,

Could Git add a user-invoked command to recover from a stale
`index.lock` when no Git process runs anymore? It could wait briefly,
then remove the lock and continue, but only if no other Git operation
contests it.

Thanks
Re: User-initiated recovery for stale index.lock
#3780
Author: Tanga Joris
Date: Wed, 25 Nov 2026 02:04
34 lines
12335 bytes
Hi Steve,

On Tue, 17 Nov 2026 at 20:51, Steve <steves.sk@gmail.com> wrote:
> Could Git add a user-invoked command to recover from a stale
> `index.lock` when no Git process runs anymore? It could wait briefly,
> then remove the lock and continue, but only if no other Git operation
> contests it.

Git already has part of this. Since Git 2.54 there is
core.lockfilePid. With it set, Git writes the PID of the lock holder
next to the lock (index~pid.lock), and if it can't take the lock, it
tells you whether that process is still running:

  Lock was held by process 99999, which is no longer running; the lock
  file appears to be stale

You still remove index.lock yourself, though.

Jun Wu also has a series in 'seen' that adds core.indexLockTimeout,
so that commands wait a little for the index lock before failing [1].
That covers your "wait briefly" suggestion.

Removing the lock automatically is tricky. A PID can be
reused by an unrelated process, and it says nothing when the
repository is also used from another machine, for example over NFS.
When the PID file was discussed, Junio was wary even of telling users
to remove the lock [2].

[1] https://lore.kernel.org/git/20261017073231.3357477-1-quark.zju@gmail.com/
[2] https://lore.kernel.org/git/xmqqbjj4hnkr.fsf@gitster.g/

Thanks,
Tanga
Re: User-initiated recovery for stale index.lock
#3802
Author: Steve
Date: Wed, 25 Nov 2026 13:06
48 lines
13438 bytes
Hi Tanga,

Thanks for the links. Since core.lockfilePid already tracks the PID,
why couldn't a manual recovery command perform that check itself and
remove the lock when explicitly invoked by the user, along with
ensuring that we wait for some reasonable time? Removing the file by
hand doesn't allow users to apply any safety checks.

Thanks,
Steve

st 25. 11. 2026 o 3:05 Tanga Joris <tangajoris@gmail.com> napรญsal(a):
>
> Hi Steve,
>
> On Tue, 17 Nov 2026 at 20:51, Steve <steves.sk@gmail.com> wrote:
> > Could Git add a user-invoked command to recover from a stale
> > `index.lock` when no Git process runs anymore? It could wait briefly,
> > then remove the lock and continue, but only if no other Git operation
> > contests it.
>
> Git already has part of this. Since Git 2.54 there is
> core.lockfilePid. With it set, Git writes the PID of the lock holder
> next to the lock (index~pid.lock), and if it can't take the lock, it
> tells you whether that process is still running:
>
>   Lock was held by process 99999, which is no longer running; the lock
>   file appears to be stale
>
> You still remove index.lock yourself, though.
>
> Jun Wu also has a series in 'seen' that adds core.indexLockTimeout,
> so that commands wait a little for the index lock before failing [1].
> That covers your "wait briefly" suggestion.
>
> Removing the lock automatically is tricky. A PID can be
> reused by an unrelated process, and it says nothing when the
> repository is also used from another machine, for example over NFS.
> When the PID file was discussed, Junio was wary even of telling users
> to remove the lock [2].
>
> [1] https://lore.kernel.org/git/20261017073231.3357477-1-quark.zju@gmail.com/
> [2] https://lore.kernel.org/git/xmqqbjj4hnkr.fsf@gitster.g/
>
> Thanks,
> Tanga
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads