Gitaly N+1 issue in spec/features/projects/merge_requests/user_comments_on_diff_spec.rb

In https://gitlab.com/gitlab-org/gitlab-ee/-/jobs/51616319:

2nd Try error in ./spec/features/projects/merge_requests/user_comments_on_diff_spec.rb:42:
 GitalyClient#migrate called 37 times from single request. Potential n+1?
The following call site called into Gitaly 2 times:
/builds/gitlab-org/gitlab-ee/lib/gitlab/gitaly_client.rb:219:in `migrate'
/builds/gitlab-org/gitlab-ee/lib/gitlab/git/repository.rb:1338:in `gitaly_migrate'
/builds/gitlab-org/gitlab-ee/lib/gitlab/git/repository.rb:1216:in `rebase_in_progress?'
/builds/gitlab-org/gitlab-ee/app/models/repository.rb:482:in `method_missing'
/builds/gitlab-org/gitlab-ee/app/models/merge_request.rb:170:in `rebase_in_progress?'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/delegator/plain_object.rb:6:in `delegate'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/entity.rb:490:in `delegate_attribute'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/exposure/delegator_exposure.rb:6:in `value'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/exposure/base.rb:79:in `valid_value'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/exposure/base.rb:63:in `serializable_value'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/exposure/nesting_exposure.rb:61:in `block (2 levels) in serializable_value'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/exposure/base.rb:109:in `block in with_attr_path'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/options.rb:102:in `with_attr_path'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/exposure/base.rb:108:in `with_attr_path'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/exposure/nesting_exposure.rb:60:in `block in serializable_value'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/exposure/nesting_exposure.rb:59:in `each'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/exposure/nesting_exposure.rb:59:in `each_with_object'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/exposure/nesting_exposure.rb:59:in `serializable_value'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/grape-entity-0.6.0/lib/grape_entity/entity.rb:471:in `serializable_hash'
/builds/gitlab-org/gitlab-ee/app/serializers/base_serializer.rb:14:in `represent'
/builds/gitlab-org/gitlab-ee/app/serializers/merge_request_serializer.rb:14:in `represent'
/builds/gitlab-org/gitlab-ee/app/helpers/issuables_helper.rb:45:in `serialize_issuable'
/builds/gitlab-org/gitlab-ee/app/views/projects/merge_requests/show.html.haml:24:in `_app_views_projects_merge_requests_show_html_haml__435424069059349666_250738920'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/actionview-4.2.10/lib/action_view/template.rb:145:in `block in render'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:166:in `instrument'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/actionview-4.2.10/lib/action_view/template.rb:333:in `instrument'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/actionview-4.2.10/lib/action_view/template.rb:143:in `render'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/actionview-4.2.10/lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/actionview-4.2.10/lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `block in instrument'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `instrument'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/actionview-4.2.10/lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
/builds/gitlab-org/gitlab-ee/vendor/ruby/2.3.0/gems/actionview-4.2.10/lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'

If we memoize Repository#rebase_in_progress? this problem appears to go away.

Assignee Loading
Time tracking Loading