diff options
author | Stan Hu <stanhu@gmail.com> | 2018-10-17 01:54:43 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-10-17 02:14:54 +0300 |
commit | 6c9e863263ca89a8b272902a61de2db0be67a7d8 (patch) | |
tree | 47523bac8570f6a3d22de39a81ebd4cacfb9a47d | |
parent | 378ee4e95db71c16e44d2b434b9277264f288552 (diff) |
Prevent stale packed-refs file when Gitaly is running on top of NFS
Users of the Linux NFS client v4.0 (and even v4.1) may encounter stale file
handles or stale data if git gc is running for a long time. A patch for this
kernel bug is here: https://marc.info/?l=linux-nfs&m=153816500525563&w=2
This workaround calls stat() on the packed-refs file to force the kernel to do
a directory entry validation on the inode.
Closes https://gitlab.com/gitlab-org/gitaly/issues/1339
-rw-r--r-- | changelogs/unreleased/sh-add-nfs-workaround.yml | 5 | ||||
-rw-r--r-- | internal/helper/repo.go | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/changelogs/unreleased/sh-add-nfs-workaround.yml b/changelogs/unreleased/sh-add-nfs-workaround.yml new file mode 100644 index 000000000..014318e3a --- /dev/null +++ b/changelogs/unreleased/sh-add-nfs-workaround.yml @@ -0,0 +1,5 @@ +--- +title: Prevent stale packed-refs file when Gitaly is running on top of NFS +merge_request: 924 +author: +type: other diff --git a/internal/helper/repo.go b/internal/helper/repo.go index 46a3cfca2..5397b2fca 100644 --- a/internal/helper/repo.go +++ b/internal/helper/repo.go @@ -81,5 +81,15 @@ func IsGitDirectory(dir string) bool { } } + // See: https://gitlab.com/gitlab-org/gitaly/issues/1339 + // + // This is a workaround for Gitaly running on top of an NFS mount. There + // is a Linux NFS v4.0 client bug where opening the packed-refs file can + // either result in a stale file handle or stale data. This can happen if + // git gc runs for a long time while keeping open the packed-refs file. + // Running stat() on the file causes the kernel to revalidate the cached + // directory entry. We don't actually care if this file exists. + os.Stat(path.Join(dir, "packed-refs")) + return true } |