DB timeout when loading environment in Projects::BlobController#show
https://sentry.gitlab.net/gitlab/gitlabcom/issues/2803866/?referrer=gitlab_plugin
PG::QueryCanceled: ERROR: canceling statement due to statement timeout
from app/finders/environments/environments_by_deployments_finder.rb:44:in `find_one'
from app/finders/environments/environments_by_deployments_finder.rb:34:in `execute'
from app/controllers/projects/blob_controller.rb:238:in `show_html'
from app/controllers/projects/blob_controller.rb:67:in `block (2 levels) in show'
...
SQL query
SELECT "environments".*
FROM "environments"
WHERE "environments"."project_id" = $1
AND ("environments"."state" IN ($2))
AND "environments"."id" IN (
SELECT "deployments"."environment_id"
FROM "deployments"
WHERE "deployments"."project_id" = $3
AND (ref = $4)
GROUP BY "deployments"."environment_id"
)
ORDER BY (
SELECT MAX("deployments"."id")
FROM "deployments"
WHERE "deployments"."environment_id" = "environments"."id"
) DESC NULLS LAST
Edited by Heinrich Lee Yu