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

Re: Concurrent fetch commands

From
Patrick Steinhardt <ps@pks.im>
Date
Jan 3, 2024, 10:40 UTC
Message-ID
<ZZU5s4LKQF1NLgnC@tanuki>
In-Reply-To
<ZZU1TCyQdLqoLxPw@ugly>
On Wed, Jan 03, 2024 at 11:22:04AM +0100, Oswald Buddenhagen wrote:
Show 12 quoted lines
> On Wed, Jan 03, 2024 at 09:11:07AM +0100, Patrick Steinhardt wrote:
> > Ah, one thing I didn't think of is parallel fetches. It's expected that
> > all of the fetches write into FETCH_HEAD at the same point in time
> > concurrently
> > 
> is it, though? given that the contents could be already randomly scrambled,
> it would not seem particularly bad if the behavior changed.
> 
> the one real complication i see is the --append option, which requires using
> a waiting lock after the actual fetch, rather than acquiring it immediately
> and erroring out on failure (and ideally giving a hint to use
> --no-write-fetch-head).

I should probably clarify, but with "parallel fetches" I meant `git fetch --jobs=`, not two separate executions of git-fetch(1). And these do in fact use `--append` internally: the main process first truncates FETCH_HEAD and then spawns its children, which will then append to FETCH_HEAD in indeterministic order.

But even though the order is indeterministic, I wouldn't go as far as claiming that the complete feature is broken. It works and records all updated refs in FETCH_HEAD just fine, even if it's not particularly elegant. Which to me shows that we should try hard not to break it.

> an extra complication is that concurrent runs with and without --append
> should be precluded, because that would again result in undefined behavior.
> it generally seems tricky to get --append straight if parallel fetches are
> supposed to work.

Yeah, the `--append` flag indeed complicates things. There are two ways to handle this:

  - `--append` should refrain from running when there is a lockfile.
    This breaks `git fetch --jobs` without extra infra to handle this
    case, and furthermore a user may (rightfully?) expect that two
    manually spawned `git fetch --append` processes should work just
    fine.
  - `--append` should handle concurrency just fine, that is it knows to
    append to a preexisting lockfile. This is messy though, and the
    original creator of the lockfile wouldn't know when it can commit it
    into place.

Both options are kind of ugly, so I'm less sure now whether lockfiles are the way to go.

Patrick
Previous: Patrick SteinhardtNext: Taylor Blau
Message 13 of 20 in “Concurrent fetch commands”
  1. Stefan HallerDec 31, 2023
  2. Dragan SimicDec 31, 2023
  3. Konstantin TokarevDec 31, 2023
  4. Dragan SimicDec 31, 2023
  5. Stefan HallerJan 1, 2024
  6. Federico KircheisJan 1, 2024
  7. Junio C HamanoDec 31, 2023
  8. Dragan SimicDec 31, 2023
  9. Stefan HallerJan 1, 2024
  10. Stefan HallerJan 1, 2024
  11. Patrick SteinhardtJan 3, 2024
  12. Patrick SteinhardtJan 3, 2024
  13. Patrick SteinhardtJan 3, 2024
  14. Taylor BlauJan 3, 2024
  15. Junio C HamanoJan 3, 2024
  16. Stefan HallerJan 4, 2024
  17. Mike HommeyJan 4, 2024
  18. Junio C HamanoJan 4, 2024
  19. Mike HommeyJan 4, 2024
  20. Taylor BlauJan 4, 2024

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.