git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: User-initiated recovery for stale index.lock

From
SSteve <steves.sk@gmail.com>
Date
Nov 25, 2026, 13:06 UTC
Message-ID
<CAAQS9U+76TGukWp+AMWN9CY_tU9kD_3Wzq9k7PzLnUqAd8SuhQ@mail.gmail.com>
In-Reply-To
<CAKrRMNpHHHHw3goFMwLKF2GRzQefcXJaXZcjY6yz_7QdbgJ_cA@mail.gmail.com>
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):
Show 34 quoted lines
>
> 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
Previous: Tanga JorisNext: Tanga Joris
Message 3 of 5 in “User-initiated recovery for stale index.lock”
  1. SteveNov 17, 2026
  2. Tanga JorisNov 25, 2026
  3. SteveNov 25, 2026
  4. Tanga JorisDec 2, 2026
  5. Tanga JorisDec 3, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.