git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Neal Kreitzinger <neal@rsss.com>
Cc: git@vger.kernel.org
Subject: Re: concurrent fetches to update same mirror
Date: Wed, 5 Jan 2011 15:47:38 -0500	[thread overview]
Message-ID: <20110105204738.GA7629@sigill.intra.peff.net> (raw)
In-Reply-To: <ig2kjt$f2u$1@dough.gmane.org>

On Wed, Jan 05, 2011 at 02:33:36PM -0600, Neal Kreitzinger wrote:

> 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

  reply	other threads:[~2011-01-05 20:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-05 20:33 concurrent fetches to update same mirror Neal Kreitzinger
2011-01-05 20:47 ` Jeff King [this message]
2011-01-05 20:51   ` Shawn Pearce
2011-01-05 20:53     ` Jeff King
2011-01-05 21:13       ` Jeff King
2011-01-05 22:34         ` Neal Kreitzinger
2011-01-05 22:42         ` Neal Kreitzinger
2011-01-05 22:57           ` Jeff King
2011-01-05 23:29         ` Junio C Hamano
2011-01-06 23:45           ` Jeff King
2011-01-07 14:50             ` Marc Branchaud
2011-01-07 14:51               ` Marc Branchaud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110105204738.GA7629@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=neal@rsss.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).