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

Re: [PATCH] git: add --no-optional-locks option

From
Jeff King <peff@peff.net>
Date
Sep 22, 2017, 16:04 UTC
Message-ID
<20170922160413.nbqhmszvdfrvz3u4@sigill.intra.peff.net>
In-Reply-To
<c474bf47-5049-1425-d03c-2417eb53549e@pobox.com>
On Fri, Sep 22, 2017 at 01:42:10AM -0500, Daniel Santos wrote:
Show 12 quoted lines
> > But taking the index lock may conflict with other operations
> > in the repository. Especially ones that the user is doing
> > themselves, which _aren't_ opportunistic. In other words,
> > "git status" knows how to back off when somebody else is
> > holding the lock, but other commands don't know that status
> > would be happy to drop the lock if somebody else wanted it.
> 
> Interestingly, this usually slaps me when performing an _interactive_
> rebase.  It occurred to me that if I'm performing an interaction
> operation, it doesn't seem unreasonable for git wait up to 125ms or so
> for the lock and then prompting the user to ask if they want to continue
> waiting for the lock.

Yes, lock timeouts would help with this situation, though not eliminate it entirely (and we've been adding some lock timeouts in a few places for related situations).

We generally avoid prompting, especially when a command can just be reissued. It sounds like "git rebase" gets into a funny state if it cannot grab the index lock. That's something that should be fixed. Even if it bails, you should be able to move forward with "rebase --continue" or similar.

Show 10 quoted lines
> That is not necessarily the case.  I don't actually know git on the
> inside, but I would ask you to consider a read-write lock and a hybrid
> of one and three.
> 
> I don't know what dotlocks are, but I'm certain that you can implement a
> rw lock using lock files and no other IPC, although it does increase the
> complexity.  The way this works is that `git status' acquires a read
> lock and does its thing.  If it has real changes, instead of discarding
> them it attempts to upgrade to a write lock.  If that fails, you throw
> it away, otherwise you write them and release.

By dotlocks, I just mean our strategy of creating O_EXCL "index.lock" files.

You're right that it can be done using two such locks, and communicating via the lockfile contents. So my "impossible" was overstating it. I do stand by my contention that it's much more complex than the existing scheme. :)

More importantly, though, it changes the locking contract completely between old and new versions (and between other implementations). There's probably only a small minority of users who might use two implementations to simultaneously access the same repository, but it is a use case we try to support. I think we'd have to require a repository-version bump to tell programs to use the new scheme.

-Peff
Previous: Daniel SantosNext: Kaartic Sivaraam
Message 16 of 26 in “git: add --no-optional-locks option”
  1. git: add --no-optional-locks optionJeff King, Sep 21, 2017
  2. Junio C HamanoSep 21, 2017
  3. Jeff KingSep 21, 2017
  4. Junio C HamanoSep 21, 2017
  5. Johannes SixtSep 21, 2017
  6. Jeff KingSep 22, 2017
  7. Jeff HostetlerSep 22, 2017
  8. Jeff KingSep 22, 2017
  9. Stefan BellerSep 22, 2017
  10. Jeff KingSep 22, 2017
  11. Stefan BellerSep 22, 2017
  12. Jeff KingSep 23, 2017
  13. Stefan BellerSep 25, 2017
  14. Jeff KingSep 27, 2017
  15. Daniel SantosSep 22, 2017
  16. Jeff KingSep 22, 2017
  17. Kaartic SivaraamSep 24, 2017
  18. Johannes SchindelinSep 25, 2017
  19. Jeff HostetlerSep 26, 2017
  20. Johannes SchindelinSep 25, 2017
  21. Jeff KingSep 25, 2017
  22. git: add --no-optional-locks optionJeff King, Sep 27, 2017
  23. Johannes SchindelinSep 28, 2017
  24. Jeff KingSep 27, 2017
  25. Kaartic SivaraamSep 27, 2017
  26. Jeff KingSep 27, 2017

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.