Skip to content

Eliminate N+1 queries in LFS file lock checks during a push

Stan Hu requested to merge sh-optimize-locks-check-ce into master

This significantly improves performance when a user pushes many references.

project.lfs_file_locks.any? doesn't cache the output and runs SELECT 1 AS one FROM "lfs_file_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.

Note that there is one more N+1 query: https://gitlab.com/gitlab-org/gitlab-ce/issues/48092

Edited by Stan Hu

Merge request reports