git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Bare repository fetch/push race condition
@ 2017-11-30 10:28 Dmitry Neverov
  2017-12-01  5:23 ` Dmitry Neverov
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Neverov @ 2017-11-30 10:28 UTC (permalink / raw)
  To: Git List

It looks like there is a race condition between fetch and push in a
bare repository in the following setup. There is a bare git repository
on a local file system. Some process pushes to this repository via
jgit. There is a cron task which pushes this repository to the backup
remote repo over ssh. We observe the following in the reflog:

6932a831843f4dbe3b394acde9adc9a8269b6cf1
57b77b8c2a04029e7f5af4d3b7e36a3ba0c7cac9 XXX 1505903078 +0200    push:
forced-update
57b77b8c2a04029e7f5af4d3b7e36a3ba0c7cac9
44a221b0271b9abc885dd6e54f691d5248c4171f XXX 1505905206 +0200    push:
forced-update
44a221b0271b9abc885dd6e54f691d5248c4171f
57b77b8c2a04029e7f5af4d3b7e36a3ba0c7cac9 YYY    1505905217 +0200
update by push

Where XXX is the process pushing via jgit and YYY is the cron task. It
looks like the cron task started a push when the ref was pointing to
57b77b8c2a04029e7f5af4d3b7e36a3ba0c7cac9 and push finished when the
ref was already updated to 44a221b0271b9abc885dd6e54f691d5248c4171f.
The push unconditionally updated the local tracking branch back to the
commit 57b77b8c2a04029e7f5af4d3b7e36a3ba0c7cac9 and we lost the commit
44a221b0271b9abc885dd6e54f691d5248c4171f since the next push from the
local process created a new commit with
57b77b8c2a04029e7f5af4d3b7e36a3ba0c7cac9 as a parent.

Shouldn't the update_ref at transport.c:308 specify the expected
old hash, like this:

    update_ref("update by push", rs.dst, ref->new_oid.hash,
ref->old_oid.hash, 0, 0);

at least for bare repositories?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bare repository fetch/push race condition
  2017-11-30 10:28 Bare repository fetch/push race condition Dmitry Neverov
@ 2017-12-01  5:23 ` Dmitry Neverov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Neverov @ 2017-12-01  5:23 UTC (permalink / raw)
  To: Dmitry Neverov; +Cc: Git List

Sorry for misleading subject. It should be "Race condition between pushing to and pushing from a bare repository"

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-01  5:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-30 10:28 Bare repository fetch/push race condition Dmitry Neverov
2017-12-01  5:23 ` Dmitry Neverov

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).