Skip to content

Projects::MergeRequestsController#ci_environments_status N+1

In https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/30224 we reduced query counts a lot.

We still have below:

Processing by Projects::MergeRequestsController#ci_environments_status as JSON
  Parameters: {"namespace_id"=>"namespace1", "project_id"=>"project1", "id"=>"1"}
  Identity Exists (0.2ms)  SELECT  1 AS one FROM "identities" WHERE "identities"."user_id" = $1 AND (provider = 'ultraauth' AND extern_uid IS NOT NULL) LIMIT $2  [["user_id", 1], ["LIMIT", 1]]
  ↳ app/models/user.rb:926
QueryRecorder SQL: SELECT  1 AS one FROM "identities" WHERE "identities"."user_id" = $1 AND (provider = 'ultraauth' AND extern_uid IS NOT NULL) LIMIT $2
   --> spec/support/helpers/query_recorder.rb:18:in `callback'
   --> app/models/user.rb:926:in `ultraauth_user?'
   --> app/controllers/concerns/enforces_two_factor_authentication.rb:27:in `two_factor_authentication_required?'
   --> app/controllers/concerns/enforces_two_factor_authentication.rb:19:in `check_two_factor_requirement'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:904:in `get_ci_environments_status'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (5 levels) in <main>'
   --> spec/support/helpers/query_recorder.rb:9:in `initialize'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `new'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `recorder'
   --> spec/support/matchers/exceed_query_limit.rb:28:in `actual_count'
   --> spec/support/matchers/exceed_query_limit.rb:58:in `verify_count'
   --> spec/support/matchers/exceed_query_limit.rb:74:in `block (2 levels) in <main>'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (4 levels) in <main>'
   --> spec/spec_helper.rb:183:in `block (2 levels) in <main>'
  Identity Exists (0.5ms)  SELECT  1 AS one FROM "identities" WHERE "identities"."user_id" = $1 AND (provider LIKE 'ldap%' AND extern_uid IS NOT NULL) LIMIT $2  [["user_id", 1], ["LIMIT", 1]]
  ↳ app/models/user.rb:918
QueryRecorder SQL: SELECT  1 AS one FROM "identities" WHERE "identities"."user_id" = $1 AND (provider LIKE 'ldap%' AND extern_uid IS NOT NULL) LIMIT $2
   --> spec/support/helpers/query_recorder.rb:18:in `callback'
   --> app/models/user.rb:918:in `ldap_user?'
   --> app/models/user.rb:838:in `allow_password_authentication_for_web?'
   --> app/models/user.rb:834:in `allow_password_authentication?'
   --> app/controllers/application_controller.rb:282:in `check_password_expiration'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:904:in `get_ci_environments_status'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (5 levels) in <main>'
   --> spec/support/helpers/query_recorder.rb:9:in `initialize'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `new'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `recorder'
   --> spec/support/matchers/exceed_query_limit.rb:28:in `actual_count'
   --> spec/support/matchers/exceed_query_limit.rb:58:in `verify_count'
   --> spec/support/matchers/exceed_query_limit.rb:74:in `block (2 levels) in <main>'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (4 levels) in <main>'
   --> spec/spec_helper.rb:183:in `block (2 levels) in <main>'
  Identity Exists (0.3ms)  SELECT  1 AS one FROM "identities" WHERE "identities"."user_id" = $1 AND (provider = 'ultraauth' AND extern_uid IS NOT NULL) LIMIT $2  [["user_id", 1], ["LIMIT", 1]]
  ↳ app/models/user.rb:926
QueryRecorder SQL: SELECT  1 AS one FROM "identities" WHERE "identities"."user_id" = $1 AND (provider = 'ultraauth' AND extern_uid IS NOT NULL) LIMIT $2
   --> spec/support/helpers/query_recorder.rb:18:in `callback'
   --> app/models/user.rb:926:in `ultraauth_user?'
   --> app/models/user.rb:838:in `allow_password_authentication_for_web?'
   --> app/models/user.rb:834:in `allow_password_authentication?'
   --> app/controllers/application_controller.rb:282:in `check_password_expiration'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:904:in `get_ci_environments_status'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (5 levels) in <main>'
   --> spec/support/helpers/query_recorder.rb:9:in `initialize'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `new'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `recorder'
   --> spec/support/matchers/exceed_query_limit.rb:28:in `actual_count'
   --> spec/support/matchers/exceed_query_limit.rb:58:in `verify_count'
   --> spec/support/matchers/exceed_query_limit.rb:74:in `block (2 levels) in <main>'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (4 levels) in <main>'
   --> spec/spec_helper.rb:183:in `block (2 levels) in <main>'
  Environment Load (0.8ms)  SELECT DISTINCT "environments".* FROM "environments" INNER JOIN "deployments" ON "environments"."id" = "deployments"."environment_id" INNER JOIN "ci_builds" ON "deployments"."deployable_id" = "ci_builds"."id" WHERE "ci_builds"."type" IN ('Ci::Build') AND "ci_builds"."commit_id" = $1 AND "deployments"."deployable_type" = $2 AND ("environments"."state" IN ('available'))  [["commit_id", 1], ["deployable_type", "CommitStatus"]]
  ↳ app/models/environment_status.rb:71
QueryRecorder SQL: SELECT DISTINCT "environments".* FROM "environments" INNER JOIN "deployments" ON "environments"."id" = "deployments"."environment_id" INNER JOIN "ci_builds" ON "deployments"."deployable_id" = "ci_builds"."id" WHERE "ci_builds"."type" IN ('Ci::Build') AND "ci_builds"."commit_id" = $1 AND "deployments"."deployable_type" = $2 AND ("environments"."state" IN ('available'))
   --> spec/support/helpers/query_recorder.rb:18:in `callback'
   --> app/models/environment_status.rb:71:in `map'
   --> app/models/environment_status.rb:71:in `build_environments_status'
   --> app/models/environment_status.rb:14:in `for_merge_request'
   --> app/controllers/projects/merge_requests_controller.rb:197:in `ci_environments_status'
   --> lib/gitlab/session.rb:11:in `with_session'
   --> app/controllers/application_controller.rb:445:in `set_session_storage'
   --> app/controllers/application_controller.rb:439:in `set_locale'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:904:in `get_ci_environments_status'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (5 levels) in <main>'
   --> spec/support/helpers/query_recorder.rb:9:in `initialize'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `new'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `recorder'
   --> spec/support/matchers/exceed_query_limit.rb:28:in `actual_count'
   --> spec/support/matchers/exceed_query_limit.rb:58:in `verify_count'
   --> spec/support/matchers/exceed_query_limit.rb:74:in `block (2 levels) in <main>'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (4 levels) in <main>'
   --> spec/spec_helper.rb:183:in `block (2 levels) in <main>'
  Project Load (1.3ms)  SELECT  "projects".* FROM "projects" WHERE "projects"."id" = $1 LIMIT $2  [["id", 2], ["LIMIT", 1]]
  ↳ app/policies/environment_policy.rb:4
QueryRecorder SQL: SELECT  "projects".* FROM "projects" WHERE "projects"."id" = $1 LIMIT $2
   --> spec/support/helpers/query_recorder.rb:18:in `callback'
   --> app/policies/environment_policy.rb:4:in `block in <class:EnvironmentPolicy>'
   --> lib/declarative_policy/base.rb:312:in `instance_eval'
   --> lib/declarative_policy/base.rb:312:in `block in delegated_policies'
   --> lib/declarative_policy/base.rb:311:in `transform_values'
   --> lib/declarative_policy/base.rb:311:in `delegated_policies'
   --> lib/declarative_policy/base.rb:268:in `runner'
   --> lib/declarative_policy/base.rb:217:in `block in allowed?'
   --> lib/declarative_policy/base.rb:217:in `all?'
   --> lib/declarative_policy/base.rb:217:in `allowed?'
   --> lib/declarative_policy/base.rb:209:in `can?'
   --> app/models/ability.rb:72:in `allowed?'
   --> app/models/environment_status.rb:72:in `block in build_environments_status'
   --> app/models/environment_status.rb:71:in `map'
   --> app/models/environment_status.rb:71:in `build_environments_status'
   --> app/models/environment_status.rb:14:in `for_merge_request'
   --> app/controllers/projects/merge_requests_controller.rb:197:in `ci_environments_status'
   --> lib/gitlab/session.rb:11:in `with_session'
   --> app/controllers/application_controller.rb:445:in `set_session_storage'
   --> app/controllers/application_controller.rb:439:in `set_locale'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:904:in `get_ci_environments_status'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (5 levels) in <main>'
   --> spec/support/helpers/query_recorder.rb:9:in `initialize'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `new'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `recorder'
   --> spec/support/matchers/exceed_query_limit.rb:28:in `actual_count'
   --> spec/support/matchers/exceed_query_limit.rb:58:in `verify_count'
   --> spec/support/matchers/exceed_query_limit.rb:74:in `block (2 levels) in <main>'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (4 levels) in <main>'
   --> spec/spec_helper.rb:183:in `block (2 levels) in <main>'
  Deployment Load (0.4ms)  SELECT  "deployments".* FROM "deployments" WHERE "deployments"."environment_id" = 1 AND "deployments"."sha" = $1 LIMIT $2  [["sha", "b83d6e391c22777fca1ed3012fce84f633d7fed0"], ["LIMIT", 1]]
  ↳ app/models/environment_status.rb:32
QueryRecorder SQL: SELECT  "deployments".* FROM "deployments" WHERE "deployments"."environment_id" = 1 AND "deployments"."sha" = $1 LIMIT $2
   --> spec/support/helpers/query_recorder.rb:18:in `callback'
   --> app/models/environment_status.rb:32:in `block in deployment'
   --> lib/gitlab/utils/strong_memoize.rb:30:in `strong_memoize'
   --> app/models/environment_status.rb:31:in `deployment'
   --> app/models/environment_status.rb:37:in `has_metrics?'
   --> app/serializers/environment_status_entity.rb:49:in `has_metrics?'
   --> app/serializers/environment_status_entity.rb:14:in `block in <class:EnvironmentStatusEntity>'
   --> app/serializers/base_serializer.rb:16:in `represent'
   --> app/controllers/projects/merge_requests_controller.rb:200:in `ci_environments_status'
   --> lib/gitlab/session.rb:11:in `with_session'
   --> app/controllers/application_controller.rb:445:in `set_session_storage'
   --> app/controllers/application_controller.rb:439:in `set_locale'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:904:in `get_ci_environments_status'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (5 levels) in <main>'
   --> spec/support/helpers/query_recorder.rb:9:in `initialize'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `new'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `recorder'
   --> spec/support/matchers/exceed_query_limit.rb:28:in `actual_count'
   --> spec/support/matchers/exceed_query_limit.rb:58:in `verify_count'
   --> spec/support/matchers/exceed_query_limit.rb:74:in `block (2 levels) in <main>'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (4 levels) in <main>'
   --> spec/spec_helper.rb:183:in `block (2 levels) in <main>'
  Project Load (0.2ms)  SELECT  "projects".* FROM "projects" WHERE "projects"."id" = $1 LIMIT $2  [["id", 2], ["LIMIT", 1]]
  ↳ app/helpers/gitlab_routing_helper.rb:29
QueryRecorder SQL: SELECT  "projects".* FROM "projects" WHERE "projects"."id" = $1 LIMIT $2
   --> spec/support/helpers/query_recorder.rb:18:in `callback'
   --> app/helpers/gitlab_routing_helper.rb:29:in `environment_metrics_path'
   --> app/serializers/environment_status_entity.rb:19:in `block in <class:EnvironmentStatusEntity>'
   --> app/serializers/base_serializer.rb:16:in `represent'
   --> app/controllers/projects/merge_requests_controller.rb:200:in `ci_environments_status'
   --> lib/gitlab/session.rb:11:in `with_session'
   --> app/controllers/application_controller.rb:445:in `set_session_storage'
   --> app/controllers/application_controller.rb:439:in `set_locale'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:904:in `get_ci_environments_status'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (5 levels) in <main>'
   --> spec/support/helpers/query_recorder.rb:9:in `initialize'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `new'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `recorder'
   --> spec/support/matchers/exceed_query_limit.rb:28:in `actual_count'
   --> spec/support/matchers/exceed_query_limit.rb:58:in `verify_count'
   --> spec/support/matchers/exceed_query_limit.rb:74:in `block (2 levels) in <main>'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (4 levels) in <main>'
   --> spec/spec_helper.rb:183:in `block (2 levels) in <main>'
  Namespace Load (0.3ms)  SELECT  "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = $1 LIMIT $2  [["id", 2], ["LIMIT", 1]]
  ↳ app/helpers/gitlab_routing_helper.rb:29
QueryRecorder SQL: SELECT  "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = $1 LIMIT $2
   --> spec/support/helpers/query_recorder.rb:18:in `callback'
   --> config/application.rb:263:in `block (4 levels) in <class:Application>'
   --> app/helpers/gitlab_routing_helper.rb:29:in `environment_metrics_path'
   --> app/serializers/environment_status_entity.rb:19:in `block in <class:EnvironmentStatusEntity>'
   --> app/serializers/base_serializer.rb:16:in `represent'
   --> app/controllers/projects/merge_requests_controller.rb:200:in `ci_environments_status'
   --> lib/gitlab/session.rb:11:in `with_session'
   --> app/controllers/application_controller.rb:445:in `set_session_storage'
   --> app/controllers/application_controller.rb:439:in `set_locale'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:904:in `get_ci_environments_status'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (5 levels) in <main>'
   --> spec/support/helpers/query_recorder.rb:9:in `initialize'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `new'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `recorder'
   --> spec/support/matchers/exceed_query_limit.rb:28:in `actual_count'
   --> spec/support/matchers/exceed_query_limit.rb:58:in `verify_count'
   --> spec/support/matchers/exceed_query_limit.rb:74:in `block (2 levels) in <main>'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (4 levels) in <main>'
   --> spec/spec_helper.rb:183:in `block (2 levels) in <main>'
  Route Load (0.2ms)  SELECT  "routes".* FROM "routes" WHERE "routes"."source_id" = $1 AND "routes"."source_type" = $2 LIMIT $3  [["source_id", 2], ["source_type", "Namespace"], ["LIMIT", 1]]
  ↳ app/models/concerns/routable.rb:99
QueryRecorder SQL: SELECT  "routes".* FROM "routes" WHERE "routes"."source_id" = $1 AND "routes"."source_type" = $2 LIMIT $3
   --> spec/support/helpers/query_recorder.rb:18:in `callback'
   --> app/models/concerns/routable.rb:99:in `full_path'
   --> app/models/namespace.rb:134:in `to_param'
   --> config/application.rb:263:in `block (4 levels) in <class:Application>'
   --> app/helpers/gitlab_routing_helper.rb:29:in `environment_metrics_path'
   --> app/serializers/environment_status_entity.rb:19:in `block in <class:EnvironmentStatusEntity>'
   --> app/serializers/base_serializer.rb:16:in `represent'
   --> app/controllers/projects/merge_requests_controller.rb:200:in `ci_environments_status'
   --> lib/gitlab/session.rb:11:in `with_session'
   --> app/controllers/application_controller.rb:445:in `set_session_storage'
   --> app/controllers/application_controller.rb:439:in `set_locale'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:904:in `get_ci_environments_status'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (5 levels) in <main>'
   --> spec/support/helpers/query_recorder.rb:9:in `initialize'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `new'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `recorder'
   --> spec/support/matchers/exceed_query_limit.rb:28:in `actual_count'
   --> spec/support/matchers/exceed_query_limit.rb:58:in `verify_count'
   --> spec/support/matchers/exceed_query_limit.rb:74:in `block (2 levels) in <main>'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (4 levels) in <main>'
   --> spec/spec_helper.rb:183:in `block (2 levels) in <main>'
  Deployment Load (0.2ms)  SELECT  "deployments".* FROM "deployments" WHERE "deployments"."environment_id" = 2 AND "deployments"."sha" = $1 LIMIT $2  [["sha", "b83d6e391c22777fca1ed3012fce84f633d7fed0"], ["LIMIT", 1]]
  ↳ app/models/environment_status.rb:32
QueryRecorder SQL: SELECT  "deployments".* FROM "deployments" WHERE "deployments"."environment_id" = 2 AND "deployments"."sha" = $1 LIMIT $2
   --> spec/support/helpers/query_recorder.rb:18:in `callback'
   --> app/models/environment_status.rb:32:in `block in deployment'
   --> lib/gitlab/utils/strong_memoize.rb:30:in `strong_memoize'
   --> app/models/environment_status.rb:31:in `deployment'
   --> app/models/environment_status.rb:37:in `has_metrics?'
   --> app/serializers/environment_status_entity.rb:49:in `has_metrics?'
   --> app/serializers/environment_status_entity.rb:14:in `block in <class:EnvironmentStatusEntity>'
   --> app/serializers/base_serializer.rb:16:in `represent'
   --> app/controllers/projects/merge_requests_controller.rb:200:in `ci_environments_status'
   --> lib/gitlab/session.rb:11:in `with_session'
   --> app/controllers/application_controller.rb:445:in `set_session_storage'
   --> app/controllers/application_controller.rb:439:in `set_locale'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:904:in `get_ci_environments_status'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (5 levels) in <main>'
   --> spec/support/helpers/query_recorder.rb:9:in `initialize'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `new'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `recorder'
   --> spec/support/matchers/exceed_query_limit.rb:28:in `actual_count'
   --> spec/support/matchers/exceed_query_limit.rb:58:in `verify_count'
   --> spec/support/matchers/exceed_query_limit.rb:74:in `block (2 levels) in <main>'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (4 levels) in <main>'
   --> spec/spec_helper.rb:183:in `block (2 levels) in <main>'
  Deployment Load (0.3ms)  SELECT  "deployments".* FROM "deployments" WHERE "deployments"."environment_id" = $1 AND "deployments"."status" = $2 ORDER BY deployments.id DESC LIMIT $3  [["environment_id", 2], ["status", 2], ["LIMIT", 1]]
  ↳ app/models/environment.rb:43
QueryRecorder SQL: SELECT  "deployments".* FROM "deployments" WHERE "deployments"."environment_id" = $1 AND "deployments"."status" = $2 ORDER BY deployments.id DESC LIMIT $3
   --> spec/support/helpers/query_recorder.rb:18:in `callback'
   --> app/models/environment.rb:43:in `stop_action'
   --> app/models/environment.rb:142:in `stop_action_available?'
   --> app/policies/environment_policy.rb:7:in `block in <class:EnvironmentPolicy>'
   --> lib/declarative_policy/condition.rb:23:in `instance_eval'
   --> lib/declarative_policy/condition.rb:23:in `compute'
   --> lib/declarative_policy/condition.rb:44:in `block in pass?'
   --> lib/declarative_policy/base.rb:282:in `cache'
   --> lib/declarative_policy/condition.rb:44:in `pass?'
   --> lib/declarative_policy/rule.rb:81:in `pass?'
   --> lib/declarative_policy/step.rb:81:in `pass?'
   --> lib/declarative_policy/runner.rb:91:in `block in run'
   --> lib/declarative_policy/runner.rb:179:in `block in steps_by_score'
   --> lib/declarative_policy/runner.rb:148:in `loop'
   --> lib/declarative_policy/runner.rb:148:in `steps_by_score'
   --> lib/declarative_policy/runner.rb:81:in `run'
   --> lib/declarative_policy/runner.rb:59:in `pass?'
   --> lib/declarative_policy/base.rb:217:in `block in allowed?'
   --> lib/declarative_policy/base.rb:217:in `all?'
   --> lib/declarative_policy/base.rb:217:in `allowed?'
   --> lib/declarative_policy/base.rb:209:in `can?'
   --> app/models/ability.rb:72:in `allowed?'
   --> lib/gitlab/allowable.rb:6:in `can?'
   --> app/serializers/environment_status_entity.rb:65:in `can_stop_environment?'
   --> app/serializers/environment_status_entity.rb:22:in `block in <class:EnvironmentStatusEntity>'
   --> app/serializers/base_serializer.rb:16:in `represent'
   --> app/controllers/projects/merge_requests_controller.rb:200:in `ci_environments_status'
   --> lib/gitlab/session.rb:11:in `with_session'
   --> app/controllers/application_controller.rb:445:in `set_session_storage'
   --> app/controllers/application_controller.rb:439:in `set_locale'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:904:in `get_ci_environments_status'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (5 levels) in <main>'
   --> spec/support/helpers/query_recorder.rb:9:in `initialize'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `new'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `recorder'
   --> spec/support/matchers/exceed_query_limit.rb:28:in `actual_count'
   --> spec/support/matchers/exceed_query_limit.rb:58:in `verify_count'
   --> spec/support/matchers/exceed_query_limit.rb:74:in `block (2 levels) in <main>'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (4 levels) in <main>'
   --> spec/spec_helper.rb:183:in `block (2 levels) in <main>'
  Namespace Load (0.4ms)  SELECT  "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = $1 LIMIT $2  [["id", 2], ["LIMIT", 1]]
  ↳ app/helpers/gitlab_routing_helper.rb:29
QueryRecorder SQL: SELECT  "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = $1 LIMIT $2
   --> spec/support/helpers/query_recorder.rb:18:in `callback'
   --> config/application.rb:263:in `block (4 levels) in <class:Application>'
   --> app/helpers/gitlab_routing_helper.rb:29:in `environment_metrics_path'
   --> app/serializers/environment_status_entity.rb:19:in `block in <class:EnvironmentStatusEntity>'
   --> app/serializers/base_serializer.rb:16:in `represent'
   --> app/controllers/projects/merge_requests_controller.rb:200:in `ci_environments_status'
   --> lib/gitlab/session.rb:11:in `with_session'
   --> app/controllers/application_controller.rb:445:in `set_session_storage'
   --> app/controllers/application_controller.rb:439:in `set_locale'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:904:in `get_ci_environments_status'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (5 levels) in <main>'
   --> spec/support/helpers/query_recorder.rb:9:in `initialize'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `new'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `recorder'
   --> spec/support/matchers/exceed_query_limit.rb:28:in `actual_count'
   --> spec/support/matchers/exceed_query_limit.rb:58:in `verify_count'
   --> spec/support/matchers/exceed_query_limit.rb:74:in `block (2 levels) in <main>'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (4 levels) in <main>'
   --> spec/spec_helper.rb:183:in `block (2 levels) in <main>'
  Route Load (0.5ms)  SELECT  "routes".* FROM "routes" WHERE "routes"."source_id" = $1 AND "routes"."source_type" = $2 LIMIT $3  [["source_id", 2], ["source_type", "Namespace"], ["LIMIT", 1]]
  ↳ app/models/concerns/routable.rb:99
QueryRecorder SQL: SELECT  "routes".* FROM "routes" WHERE "routes"."source_id" = $1 AND "routes"."source_type" = $2 LIMIT $3
   --> spec/support/helpers/query_recorder.rb:18:in `callback'
   --> app/models/concerns/routable.rb:99:in `full_path'
   --> app/models/namespace.rb:134:in `to_param'
   --> config/application.rb:263:in `block (4 levels) in <class:Application>'
   --> app/helpers/gitlab_routing_helper.rb:29:in `environment_metrics_path'
   --> app/serializers/environment_status_entity.rb:19:in `block in <class:EnvironmentStatusEntity>'
   --> app/serializers/base_serializer.rb:16:in `represent'
   --> app/controllers/projects/merge_requests_controller.rb:200:in `ci_environments_status'
   --> lib/gitlab/session.rb:11:in `with_session'
   --> app/controllers/application_controller.rb:445:in `set_session_storage'
   --> app/controllers/application_controller.rb:439:in `set_locale'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:904:in `get_ci_environments_status'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (5 levels) in <main>'
   --> spec/support/helpers/query_recorder.rb:9:in `initialize'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `new'
   --> spec/support/matchers/exceed_query_limit.rb:33:in `recorder'
   --> spec/support/matchers/exceed_query_limit.rb:28:in `actual_count'
   --> spec/support/matchers/exceed_query_limit.rb:58:in `verify_count'
   --> spec/support/matchers/exceed_query_limit.rb:74:in `block (2 levels) in <main>'
   --> spec/controllers/projects/merge_requests_controller_spec.rb:893:in `block (4 levels) in <main>'
   --> spec/spec_helper.rb:183:in `block (2 levels) in <main>'
Completed 200 OK in 166ms (Views: 0.3ms | ActiveRecord: 26.4ms)
Edited by Thong Kuah