Skip to content

Remove Eager Load of last_deployment in EnvironmentFolder

Jason Goodman requested to merge remove-includes-from-environment-dashboard into master

What does this MR do?

Eager loading the last_deployment here loads all the deployments and all the ci_builds for every environment in the Environment Dashboard.

This can cause a 500 error with ActiveRecord::QueryCanceled: PG::QueryCanceled: ERROR: canceling statement due to statement timeout with a project with enough data: https://log.gitlab.net/goto/f243231ba1b382b150b3eda3d8732ce7

Sentry: https://sentry.gitlab.net/gitlab/gitlabcom/issues/1006912/events/20492111/

I would imagine this is at least part of the culprit of the performance issues we've been discussing in !17645 (merged)

In contrast, if we don't preload these associations, we load one Deployment and one Ci::Build for each Environment (2 queries, each of which use a LIMIT 1 clause).

I would say we revert this to an N+1 to fix this issue. It may not solve all our problems, but I think it's a step in the right direction.

Related Issues: #3713 (closed), #33609 (closed)

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Performance and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Jason Goodman

Merge request reports