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

Re: User-initiated recovery for stale index.lock

From
TJTanga Joris <tangajoris@gmail.com>
Date
Dec 2, 2026, 21:52 UTC
Message-ID
<CAKrRMNo2wMmoQY0Cy9q3DgwUuTTZEFBm2un2Ut-F1LFneBoRWw@mail.gmail.com>
In-Reply-To
<CAAQS9U+76TGukWp+AMWN9CY_tU9kD_3Wzq9k7PzLnUqAd8SuhQ@mail.gmail.com>
Hi Steve,
On Wed, 25 Nov 2026 at 16:07, Steve <steves.sk@gmail.com> wrote:
Show 5 quoted lines
> 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.

That's a fair point. A command could check things that removing the file by hand doesn't.

The problem is that the check can be wrong. If Git is killed while it holds the lock, both index.lock and index~pid.lock are left behind. If you then remove only index.lock, the next Git process can't write its own PID file, because the old one is still there. So the old PID stays.

I tried running "git commit" with the old PID file still there, and left its editor open. Then "git add" in another terminal said:

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

So a command that trusts this check would remove a lock that is still in use. It also means index~pid.lock has to be removed together with index.lock.

Waiting wouldn't help much here. If the lock is stale, it stays there no matter how long we wait. And "git commit" keeps the lock for as long as its editor is open, so a lock that is still in use can also be there for minutes.

Also, the PID file doesn't say which machine the process is on. So if the repository is shared over NFS, a process on another machine that holds the lock can look gone from here.

Thanks, Tanga

Previous: SteveNext: Tanga Joris
Message 4 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.