All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Scott Sandler <scott.m.sandler@gmail.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: Git push race condition?
Date: Mon, 24 Mar 2014 18:51:36 -0400	[thread overview]
Message-ID: <20140324225136.GA17080@sigill.intra.peff.net> (raw)
In-Reply-To: <CACBZZX4ZEPA3sBp4-3QF6de0EWXzPkcOiqSxH3_CXV27Z=gxtw@mail.gmail.com>

On Mon, Mar 24, 2014 at 10:16:52PM +0100, Ævar Arnfjörð Bjarmason wrote:

> > error: Ref refs/heads/master is at
> > 4584c1f34e07cea2df6abc8e0d407fe016017130 but expected
> > 61b79b6d35b066d054fb3deab550f1c51598cf5f
> > remote: error: failed to lock refs/heads/master
> 
> I also see this error once in a while. I read the code a while back
> and it's basically because there's two levels of locks that
> receive-pack tries to get, and it's possible for two pushers to get
> the first lock due to a race condition.
> 
> I've never seen data loss due to this though, because the inner lock is atomic.

The reason is that there are not 2 locks. Each side remembers the "old"
value when it started the operation, and only takes a lock when it comes
time to write the ref (and then checks that the old value is still
current). Two pushes happening simultaneously do not have any idea that
the other is occurring.

-Peff

  parent reply	other threads:[~2014-03-24 22:51 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-24 19:18 Git push race condition? Scott Sandler
2014-03-24 19:44 ` Matthieu Moy
2014-03-24 20:01   ` Scott Sandler
2014-03-24 22:09     ` Matthieu Moy
2014-03-24 22:44       ` Junio C Hamano
2014-03-24 21:16 ` Ævar Arnfjörð Bjarmason
2014-03-24 21:29   ` Scott Sandler
2014-03-24 22:51   ` Jeff King [this message]
2014-03-24 22:54 ` Jeff King
2014-03-24 22:59   ` Nasser Grainawi
2014-03-25 13:45     ` Scott Sandler
2014-03-25 14:03       ` Matthieu Moy
2014-03-25 14:16         ` Scott Sandler
2014-03-25 14:22           ` Matthieu Moy
2014-03-25 14:57       ` Jeff King
2014-04-10 19:14         ` Scott Sandler
2014-04-11  7:46           ` Matthieu Moy

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=20140324225136.GA17080@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=scott.m.sandler@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.