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

Re: concurrent fetches to update same mirror

From
Jeff King <peff@peff.net>
Date
Jan 5, 2011, 20:47 UTC
Message-ID
<20110105204738.GA7629@sigill.intra.peff.net>
In-Reply-To
<ig2kjt$f2u$1@dough.gmane.org>
On Wed, Jan 05, 2011 at 02:33:36PM -0600, Neal Kreitzinger wrote:
Show 6 quoted lines
> If two or more different users perform a git-fetch on the same mirror 
> (--mirror) repo concurrently, could that cause corruption?  I tried a manual 
> test using the git protocol over separate machines and they both thought 
> they needed to do the full updates and they both appeared to work.  I'm not 
> sure if git is serializing this, or if it is possible for concurrent fetches 
> to step on each other.

No, it shouldn't cause corruption, but it will cause wasted effort and it may cause one to report failure. The fetch process gets all of the objects first, and then updates the ref (so we never have refs that point to object we didn't get yet). So both of the concurrent fetches will see that we have a big set of objects to get and will work on getting them at the same time, after which they will update the refs appropriately (presumably to the same thing).

I haven't looked specifically at how fetch does locking, but usually the procedure is to lock the ref, fetch the old value, unlock it, then do some long-running task (like fetching objects), then lock again, check that the old value didn't change out from under us, update it, then unlock. In which case one of the fetches might see "oops, somebody updated while we were fetching" and complain.

However, in the default configuration, we fetch using a "+" refspec, which forces update of the ref even in the case of a non-fast-forward. I don't know whether that force also would override any lock-checking.

-Peff
Previous: Neal KreitzingerNext: Shawn Pearce
Message 2 of 12 in “concurrent fetches to update same mirror”
  1. Neal KreitzingerJan 5, 2011
  2. Jeff KingJan 5, 2011
  3. Shawn PearceJan 5, 2011
  4. Jeff KingJan 5, 2011
  5. Jeff KingJan 5, 2011
  6. Neal KreitzingerJan 5, 2011
  7. Neal KreitzingerJan 5, 2011
  8. Jeff KingJan 5, 2011
  9. Junio C HamanoJan 5, 2011
  10. Jeff KingJan 6, 2011
  11. Marc BranchaudJan 7, 2011
  12. Marc BranchaudJan 7, 2011

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.