summaryrefslogtreecommitdiff
path: root/lib/gitlab/gitaly_client
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-03-16 23:23:11 -0700
committerStan Hu <stanhu@gmail.com>2019-03-27 14:46:39 -0500
commitdb759c5d9ca3ba9c1610b05d6725c1427d653bef (patch)
tree08fedc19236dd8c0c317179c93c7ca09f228eeff /lib/gitlab/gitaly_client
parentc624c61a0c65d9b61c06579840d3fb11207b20e7 (diff)
downloadgitlab-ce-db759c5d9ca3ba9c1610b05d6725c1427d653bef.tar.gz
Allow ref name caching CommitService#find_commit
For a given merge request, it's quite common to see duplicate FindCommit Gitaly requests because the Gitaly CommitService caches the request by the commit SHA, not by the ref name. However, most of the duplicate requests use the ref name, so the cache is never actually used in practice. This leads to unnecessary requests that slow performance. This commit allows certain callers to bypass the ref name to OID conversion in the cache. We don't do this by default because it's possible the tip of the branch changes during the commit, which would cause the caller to get stale data. This commit also forces the Ci::Pipeline to use the full ref name so that caching can work for merge requests. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/57083
Diffstat (limited to 'lib/gitlab/gitaly_client')
-rw-r--r--lib/gitlab/gitaly_client/commit_service.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb
index ea12424eb4a..0d5debfcd01 100644
--- a/lib/gitlab/gitaly_client/commit_service.rb
+++ b/lib/gitlab/gitaly_client/commit_service.rb
@@ -286,7 +286,7 @@ module Gitlab
commit = call_find_commit(revision)
return unless commit
- key[:commit_id] = commit.id
+ key[:commit_id] = commit.id unless GitalyClient.ref_name_caching_allowed?
Gitlab::SafeRequestStore[key] = commit
else
call_find_commit(revision)