threads / discuss / 38209

Are simultaneous fetches safe?

Subject: Are simultaneous fetches safe?

## tl;dr

One message between Dec 19, 2014 and Dec 19, 2014.

replies: 0people: 1as markdown or json

Craig Silverstein· Dec 19, 2014, 19:17 UTC · lore
(Separated out from another thread since this issue seems more general.)

I am planning to use 'git new-workdir', which basically lets several workspaces share a single .git/refs directory. (Among other dirs in .git) It's possible that I'll end up running 'git fetch' in these workspaces simultaneously, meaning they'll be trying to update .git/ref at the same time. Is this safe? I know there's a push-lock, but there doesn't seem to be a fetch-lock.

When I tried it, I got some errors:
Running 'git fetch' in window 1:
---
khan% git fetch origin
remote: Counting objects: 37, done.
remote: Compressing objects: 100% (37/37), done.
remote: Total 37 (delta 11), reused 0 (delta 0)
Unpacking objects: 100% (37/37), done.
From github.com:Khan/webapp
   1f893f3..a9d6739  master     -> origin/master
   2641d9f..b630758  athena     -> origin/athena
 + 2a83b90...b7ca8be chris      -> origin/chris  (forced update)
   0e74194..a9d6739  sat        -> origin/sat
 * [new tag]         gae-1219-0726-b7ca8bef9b50 -> gae-1219-0726-b7ca8bef9b50
 * [new tag]         gae-1219-0908-a9d67391b44c -> gae-1219-0908-a9d67391b44c
---
Running 'git fetch' in window2 at the same time, in the same directory:
---
khan% git fetch origin
error: Ref refs/remotes/origin/master is at
a9d67391b44cc8df8336afbc0b0a53691eae1bd4 but expected
1f893f3a4d78012964fc7fb93d1f61eacb1b4858
From github.com:Khan/webapp
 ! 1f893f3..a9d6739  master     -> origin/master  (unable to update local ref)
error: Ref refs/remotes/origin/athena is at
b63075834f77e494c56aade8ef8d7154f174865c but expected
2641d9ff052769aca8919c5528f02d65210a12cf
 ! 2641d9f..b630758  athena     -> origin/athena  (unable to update local ref)
error: Ref refs/remotes/origin/chris is at
b7ca8bef9b5011aa763104f1193b60dd91e0ba0c but expected
2a83b9042cfd1d73970cf0333910f4db978fbc71
 ! 2a83b90...b7ca8be chris      -> origin/chris  (unable to update local ref)
error: Ref refs/remotes/origin/sat is at
a9d67391b44cc8df8336afbc0b0a53691eae1bd4 but expected
0e74194f8a07a13dbae023f88d9cdf2ddcc3566f
 ! 0e74194..a9d6739  sat        -> origin/sat  (unable to update local ref)
 * [new tag]         gae-1219-0726-b7ca8bef9b50 -> gae-1219-0726-b7ca8bef9b50
 * [new tag]         gae-1219-0908-a9d67391b44c -> gae-1219-0908-a9d67391b44c
---

Are these errors benign, or is there the risk of corruption of some kind? Is there the possibility of corruption in other dirs as well, such as .git/objects?

Is it possible that both fetch's could prompt a gc run, and if so, is there a risk that two gc's running simultaneously could cause problems?

(Here's the full list of .git dirs shared across workspaces, according
to https://github.com/git/git/blob/master/contrib/workdir/git-new-workdir):
   config refs logs/refs objects info hooks packed-refs remotes rr-cache svn

Thanks, craig

← back to recent threads