Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Tobler <jtobler@gitlab.com>2023-05-25 18:45:03 +0300
committerJustin Tobler <jtobler@gitlab.com>2023-05-25 18:45:03 +0300
commitacb43c89009d79d352384efaa0005939ce58096b (patch)
tree287be3490f3c8fd2357cdf07379e0178898e99db
parent3012ec2e72d093a382712b6946e24618978a9dcc (diff)
parentb0a54103612c2e4b9dd2356e79b5897058cf1543 (diff)
Merge branch 'pks-git-increase-packed-refs-timeout' into 'master'
git: Extend locking timeout for packed-refs to decrease contention Closes #5160 See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/5833 Merged-by: Justin Tobler <jtobler@gitlab.com> Approved-by: Justin Tobler <jtobler@gitlab.com> Approved-by: karthik nayak <knayak@gitlab.com> Co-authored-by: Patrick Steinhardt <psteinhardt@gitlab.com>
-rw-r--r--internal/git/command_factory.go15
-rw-r--r--internal/git/command_factory_test.go1
2 files changed, 16 insertions, 0 deletions
diff --git a/internal/git/command_factory.go b/internal/git/command_factory.go
index 97e54fa69..11f7f4eba 100644
--- a/internal/git/command_factory.go
+++ b/internal/git/command_factory.go
@@ -595,6 +595,21 @@ func (cf *ExecCommandFactory) GlobalConfiguration(ctx context.Context) ([]Config
// likelihood of repository corruption in case the server crashes.
{Key: "core.fsync", Value: "objects,derived-metadata,reference"},
{Key: "core.fsyncMethod", Value: "fsync"},
+
+ // When deleting references, Git needs to rewrite the `packed-refs` file to evict
+ // the reference from it. In order to not race with concurrent writers it thus needs
+ // to lock the file for concurrent access. This lock is thus a shared resource, and
+ // in high-activity repositories we see a lot of contention around this lock: for
+ // once because we typically have many writes there, but second because these repos
+ // tend to have many references and thus rewriting the `packed-refs` file takes
+ // proportionally longer.
+ //
+ // Git has a default timeout of 1 second to try and lock the file. In practice
+ // though we see that this is not sufficient, and epsecially the `DeleteRefs` RPC is
+ // erroring out very frequently. We thus increase the timeout to 10 seconds. While
+ // comparatively high, context cancellation would still cause us to exit early in
+ // case the caller doesn't want to wait this long.
+ {Key: "core.packedRefsTimeout", Value: "10000"},
}
return config, nil
diff --git a/internal/git/command_factory_test.go b/internal/git/command_factory_test.go
index ba57a5f7a..d361f4626 100644
--- a/internal/git/command_factory_test.go
+++ b/internal/git/command_factory_test.go
@@ -612,6 +612,7 @@ func TestExecCommandFactory_config(t *testing.T) {
"core.usereplacerefs=false",
"core.fsync=objects,derived-metadata,reference",
"core.fsyncmethod=fsync",
+ "core.packedrefstimeout=10000",
}
gitCmdFactory := gittest.NewCommandFactory(t, cfg)