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

Re: [PATCH 0/1] Fix UX issue with commit-graph.lock

From
Junio C Hamano <gitster@pobox.com>
Date
May 10, 2018, 07:00 UTC
Message-ID
<xmqqfu30j8q7.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180509141523.89896-1-dstolee@microsoft.com>
Derrick Stolee <dstolee@microsoft.com> writes:
Show 14 quoted lines
> We use the lockfile API to avoid multiple Git processes from writing to
> the commit-graph file in the .git/objects/info directory. In some cases,
> this directory may not exist, so we check for its existence.
>
> The existing code does the following when acquiring the lock:
>
> 1. Try to acquire the lock.
> 2. If it fails, try to create the .git/object/info directory.
> 3. Try to acquire the lock, failing if necessary.
>
> The problem is that if the lockfile exists, then the mkdir fails, giving
> an error that doesn't help the user:
>
>   "fatal: cannot mkdir .git/objects/info: File exists"

Isn't a better immediate fix to make the second step pay attention to errno? If mkdir() failed due to EEXIST, then we know we tried to aquire the lock already, so we can die with an appropriate message.

That way, we can keep the "optimize for the normal case" that the approach to assume object/info/ directory is already there, instead of always checking its existence which is almost always true beforehand.

Also, can't we tell why we failed to acquire the lock at step #1? Do we only get a NULL that says "I am not telling you why, but we failed to lock"? What I am getting at is that the ideal sequence would be more like:

    1. Try to acquire the lock.
    2-a. if #1 succeeds, we are happy. ignore the rest and return
         the lock.
    2-b. if #1 failed because object/info/ did not exist,
         mkdir() it, and die if we cannot, saying "cannot mkdir".
	 if mkdir() succeeds, jump t 3.
    2-c. if #1 failed but that is not due to missing object/info/,
	 die saying "cannot lock".
    3. Try to acquire the lock.
    4-a. if #3 succeeds, we are happy.ignore the rest and return
         the lock.
    4-b. die saying "cannot lock".
Previous: Duy NguyenNext: Derrick Stolee
Message 7 of 11 in “Fix UX issue with commit-graph.lock”
  1. 0/1 Fix UX issue with commit-graph.lockDerrick Stolee, May 9, 2018
  2. 1/1 commit-graph: fix UX issue when .lock file existsDerrick Stolee, May 9, 2018
  3. Jeff KingMay 9, 2018
  4. Derrick StoleeMay 9, 2018
  5. Jeff KingMay 10, 2018
  6. Duy NguyenMay 9, 2018
  7. Junio C HamanoMay 10, 2018
  8. Derrick StoleeMay 10, 2018
  9. Junio C HamanoMay 11, 2018
  10. commit-graph: fix UX issue when .lock file existsDerrick Stolee, May 10, 2018
  11. Jeff KingMay 11, 2018

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.