Gitlab::DataBuilder::Push is calling Gitaly n+1 times per invocation

Gitlab::DataBuilder::Push#build is calling Gitaly n+1 times per request.

This is being called from the post_receive worker on push.

https://gitlab.com/gitlab-org/gitlab-ce/blob/post_receive_n_plus_1_workaround/lib/gitlab/data_builder/push.rb#L56

 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/lib/gitlab/git/commit.rb:314:in `deltas'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/app/models/commit.rb:359:in `raw_deltas'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/app/models/commit.rb:395:in `repo_changes'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/app/models/commit.rb:170:in `hook_attrs'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/lib/gitlab/data_builder/push.rb:68:in `block in build'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/lib/gitlab/data_builder/push.rb:67:in `map'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/lib/gitlab/data_builder/push.rb:67:in `build'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/app/services/git_push_service.rb:178:in `build_push_data'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/app/services/git_push_service.rb:130:in `execute_related_hooks'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/app/services/git_push_service.rb:56:in `execute'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/app/workers/post_receive.rb:43:in `block in process_project_changes'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/lib/gitlab/git_post_receive.rb:22:in `block in changes_refs'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/lib/gitlab/git_post_receive.rb:19:in `each'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/lib/gitlab/git_post_receive.rb:19:in `changes_refs'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/app/workers/post_receive.rb:32:in `process_project_changes'
 /Users/andrewn/code/gitlab/gitlab-development-kit/gitlab/app/workers/post_receive.rb:22:in `perform'

The problem seems to be related to repo_changes for each commit in the push

Edited Jun 30, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading