summaryrefslogtreecommitdiff
path: root/lib/gitlab/checks
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-06-18 16:38:34 -0700
committerStan Hu <stanhu@gmail.com>2018-06-18 16:42:20 -0700
commit4f9068dfc06269ca7e2247fb0be2796452546de1 (patch)
treeb8a4f61fb70187d1085d7ad0dacf08babf5c3b86 /lib/gitlab/checks
parent02c007bda52ac4cbcc8df98e2faf9273745bf951 (diff)
downloadgitlab-ce-4f9068dfc06269ca7e2247fb0be2796452546de1.tar.gz
Eliminate N+1 queries in LFS file locks checks during a pushsh-optimize-locks-check-ce
This significantly improves performance when a user pushes many references. project.path_locks.any? doesn't cache the output and runs `SELECT 1 AS one FROM "path_locks" WHERE project_id = N` each time. When there are thousands of refs being pushed, this can time out the unicorn worker. CE port for https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/6159.
Diffstat (limited to 'lib/gitlab/checks')
-rw-r--r--lib/gitlab/checks/commit_check.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/gitlab/checks/commit_check.rb b/lib/gitlab/checks/commit_check.rb
index 43a52b493bb..22310e313ac 100644
--- a/lib/gitlab/checks/commit_check.rb
+++ b/lib/gitlab/checks/commit_check.rb
@@ -37,7 +37,7 @@ module Gitlab
def validate_lfs_file_locks?
strong_memoize(:validate_lfs_file_locks) do
- project.lfs_enabled? && project.lfs_file_locks.any? && newrev && oldrev
+ project.lfs_enabled? && newrev && oldrev && project.any_lfs_file_locks?
end
end