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

Re: [PATCH v3 2/2] setup: don't fail if commondir reference is deleted.

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Feb 21, 2019, 09:27 UTC
Message-ID
<CAPig+cT48d9JJyqVx0WvBiFV+BLqAqo5dX3yndNhoJZmKRPgEg@mail.gmail.com>
In-Reply-To
<CAPig+cS4vZpyj4Cx=Q89v3xTrCG4WbtX8EhTfOT2RKytjV-HrA@mail.gmail.com>
On Wed, Feb 20, 2019 at 1:35 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 21 quoted lines
> On Wed, Feb 20, 2019 at 12:16 PM Michal Suchánek <msuchanek@suse.de> wrote:
> > On Wed, 20 Feb 2019 11:55:46 -0500
> > Eric Sunshine <sunshine@sunshineco.com> wrote:
> > > On Wed, Feb 20, 2019 at 11:17 AM Michal Suchanek <msuchanek@suse.de> wrote:
> > > > Another even rarer issue is that the file might be zero size because another
> > > > process initializing a worktree opened the file but has not written is content
> > > > yet.
> > >
> > > Based upon the explanation thus far, I'm having trouble understanding
> > > under what circumstances these race conditions can arise. Are you
> > > trying to invoke Git commands in a particular worktree even as the
> > > worktree itself is being created?
> >
> > It's explained in the following paragraph. If you have multiple
> > worktrees some *other* worktreee may be uninitialized.
>
> I understand that, but setup.c:get_common_dir_noenv() is concerned
> only with _this_ worktree -- the one in which the Git command is being
> run -- so it's not clear if or how some other partially-initialized
> worktree could have any impact. (And, I'm having trouble fathoming how
> it could, which is why I'm asking these questions).

I still can't see how setup.c:get_common_dir_noenv() could be responsible for the behavior you're describing of _any_ Git command erroring out due to _any_ worktree being incompletely-initialized. However, I can imagine "git worktree add" itself being racy and failing due to a missing or empty "commondir" file for some other worktree since that command _does_ consult other worktree entries when validating the "add" operation via builtin/worktree.c:validate_worktree_add() which calls get_worktrees(). If get_worktrees() is subject to that raciness problem, then "git worktree add" will inherit that undesirable raciness behavior (as will other "git worktree" commands which call get_worktrees(), such as "git worktree list").

> Is it possible that when you saw that error message, it actually arose
> from some code other than setup.c:get_common_dir_noenv()?

So, I'm suspecting get_worktrees() or some function it calls (and so on) as the racy culprit.

Previous: Eric SunshineNext: Michal Suchánek
Message 25 of 27 in “worktree add race fix”
  1. 0/2 worktree add race fixMichal Suchanek, Feb 18, 2019
  2. 1/2 worktree: fix worktree add race.Michal Suchanek, Feb 18, 2019
  3. 2/2 setup: don't fail if commondir reference is deleted.Michal Suchanek, Feb 18, 2019
  4. Eric SunshineFeb 18, 2019
  5. Duy NguyenFeb 21, 2019
  6. Michal SuchánekFeb 21, 2019
  7. Phillip WoodFeb 21, 2019
  8. Eric SunshineFeb 21, 2019
  9. Phillip WoodFeb 21, 2019
  10. Michal SuchánekMar 4, 2019
  11. Michal SuchánekFeb 21, 2019
  12. Duy NguyenFeb 22, 2019
  13. Phillip WoodFeb 22, 2019
  14. Duy NguyenFeb 22, 2019
  15. 1/2 worktree: fix worktree add race.Michal Suchanek, Feb 20, 2019
  16. Eric SunshineFeb 20, 2019
  17. Michal SuchánekFeb 20, 2019
  18. Duy NguyenMar 8, 2019
  19. Eric SunshineMar 8, 2019
  20. Junio C HamanoMar 11, 2019
  21. 2/2 setup: don't fail if commondir reference is deleted.Michal Suchanek, Feb 20, 2019
  22. Eric SunshineFeb 20, 2019
  23. Michal SuchánekFeb 20, 2019
  24. Eric SunshineFeb 20, 2019
  25. Eric SunshineFeb 21, 2019
  26. Michal SuchánekFeb 21, 2019
  27. Michal SuchánekFeb 21, 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.