Skip to content

Cache any_project_with_shared_runners_enabled?

Adam Hegyi requested to merge cache_any_project_with_shared_runners_enabled into master

What does this MR do?

This MR caches the any_project_with_shared_runners_enabled? method.

The method caused a few production incidents and we had problems also on self-managed. The underlying query comes up regurarly in the top 10 most resource consuming queries list:

/*application:web,correlation_id:01FC9JZ1RXPB9970CKX43DYSZA,endpoint_id:PUT /api/:version/jobs/:id*/ SELECT $1 AS one FROM "projects" WHERE "projects"."namespace_id" IN (SELECT traversal_ids[array_length(traversal_ids, $2)] AS id FROM "namespaces" WHERE (traversal_ids @> ($3))) AND "projects"."shared_runners_enabled" = $4 LIMIT $5

Optimizing the query is possible with a recursive CTE (https://explain.depesz.com/s/J7V9#html) however, it would not work for all namespaces.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • 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 Adam Hegyi

Merge request reports