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

Re: Bug: fatal: Unable to create '.../.git/index.lock': File exists.

From
Duy Nguyen <pclouds@gmail.com>
Date
May 2, 2019, 16:38 UTC
Message-ID
<CACsJy8Dimn9+ogDNEgy3xmLunyX_pStBq=g-1jrf74LsOW1xrA@mail.gmail.com>
In-Reply-To
<20190502150701.GA14906@sigill.intra.peff.net>
On Thu, May 2, 2019 at 10:07 PM Jeff King <peff@peff.net> wrote:
Show 15 quoted lines
>
> On Thu, May 02, 2019 at 04:45:36PM +0300, Aleksey Midenkov wrote:
>
> > > Assuming that kdevelop is just running "git status" in the background,
> > > though, there's an easier solution. If it uses "git --no-optional-locks
> > > status" instead, that will instruct it not to take the index lock at
> > > all.
> >
> > And can we disable optional locks at git configuration level? Because
> > changing source code of each application that is not aware of this
> > option is not an easier solution.
>
> Since the decision of whether to use the locks is dependent on the
> operation being performed, it's an environment variable and not a config
> option.

And there's also tradeoff for doing it. If git-status will not take locks, it cannot update the index to save refresh information and reuse the next time. git-status may become more and more expensive over time (*). Setting a config variable for this does not sound like a good idea at all. The same for setting GIT_OPTIONAL_LOCKS=0 in ~/.bashrc to "fix" the problem once and for all.

I might take a stab at the "wait and try to hold the lock again, doing necessary verification after if needed" idea. It sounds like the right way to go and we haven't had problems with refs doing the same thing (have we?).

(*) not entirely true since other commands can also refresh and save. But in the ideal world when optional locks are used for all optional updates, it's true.

Show 6 quoted lines
> You should be able to do:
>
>   GIT_OPTIONAL_LOCKS=0 kdevelop
>
> and any commands run by kdevelop will avoid taking locks when they can
> (but for now, the only command which does this is git-status anyway).
-- 
Duy
Previous: Jeff KingNext: Jeff King
Message 9 of 15 in “Bug: fatal: Unable to create '.../.git/index.lock': File exists.”
  1. Aleksey MidenkovApr 29, 2019
  2. Duy NguyenApr 29, 2019
  3. Aleksey MidenkovApr 30, 2019
  4. Jeff KingApr 30, 2019
  5. Aleksey MidenkovMay 1, 2019
  6. Jeff KingMay 1, 2019
  7. Aleksey MidenkovMay 2, 2019
  8. Jeff KingMay 2, 2019
  9. Duy NguyenMay 2, 2019
  10. Jeff KingMay 2, 2019
  11. Duy NguyenMay 2, 2019
  12. Johannes SchindelinMay 3, 2019
  13. Duy NguyenMay 3, 2019
  14. Duy NguyenMay 3, 2019
  15. Johannes SchindelinApr 29, 2019

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.