N+1 in PipelinesController#show.json loading failed builds

If you pull up the pipelines page with lots of failed builds:

image

You see lots of these:

image

I think it's from https://gitlab.com/gitlab-org/gitlab-ee/blob/05f03b390fbcc06650ddc06bdb8f265ea20fe3c0/app/serializers/pipeline_entity.rb#L81:

pipeline.builds.failed

Backtrace:

[
  "app/serializers/base_serializer.rb:16:in `represent'",
  "app/serializers/concerns/with_pagination.rb:21:in `represent'",
  "app/serializers/pipeline_serializer.rb:21:in `represent'",
  "app/controllers/projects/pipelines_controller.rb:183:in `serialize_pipelines'",
  "app/controllers/projects/pipelines_controller.rb:43:in `block (2 levels) in index'",
  "app/controllers/projects/pipelines_controller.rb:37:in `index'",
  "app/controllers/application_controller.rb:533:in `block in allow_gitaly_ref_name_caching'",
  "lib/gitlab/gitaly_client.rb:314:in `allow_ref_name_caching'",
  "app/controllers/application_controller.rb:532:in `allow_gitaly_ref_name_caching'",
  "ee/lib/gitlab/ip_address_state.rb:10:in `with'",
  "ee/app/controllers/ee/application_controller.rb:43:in `set_current_ip_address'",
  "lib/gitlab/session.rb:11:in `with_session'",
  "app/controllers/application_controller.rb:450:in `set_session_storage'",
  "app/controllers/application_controller.rb:444:in `set_locale'",
  "ee/lib/gitlab/jira/middleware.rb:19:in `call'"
]
Edited Sep 25, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading