Skip to content

Per-commit checks in ChangeAccess are too slow

Summary

Pushes time out with internal API unreachable due to Checks::ChangeAccess#commits_check being too slow.

This appears to be caused by us doing a raw git lookup for every single new commit in the push.

Steps to reproduce

  1. Clone gitlab-org/gitlab-ce repo
  2. Create new project on GitLab.com or local dev instance and add as remote
  3. Enable a per commit check, such as file locking or file name regex checks.
  4. Push master branch to new project
  5. This fails with GitLab: API is not accessible
remote: Resolving deltas: 100% (490366/490366), done.
remote: Checking connectivity: 629646, done.
remote: GitLab: API is not accessible
To gitlab.com:jamedjo/test-ce.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@gitlab.com:jamedjo/test-ce.git'

Locally additional logging can be added in Repository#new_commits to spot that the timeout happens there:

    logger = Logger.new("#{Rails.root}/log/change_access.log")
    logger.info("COMMIT rev_list: #{sha}")

My local machine was able to process around 364 commits in the 60 seconds, or around 160ms per commit. This is particularly troubling when trying to do a first push into a project, where we might expect ~10,000 commits.

Possible fixes

Related

Edited by James Edwards-Jones