Zoekt: Fix scheduling service statement timeout
What does this MR do and why?
This MR fixes ActiveRecord::QueryCanceled
exception in Search::Zoekt::SchedulingService
The problematic spot was the GitlabSubscription
subquery
Query before
SELECT "namespaces"."id", "namespaces"."name", "namespaces"."path", "namespaces"."owner_id", "namespaces"."created_at", "namespaces"."updated_at", "namespaces"."type", "namespaces"."description", "namespaces"."avatar", "namespaces"."membership_lock", "namespaces"."share_with_group_lock", "namespaces"."visibility_level", "namespaces"."request_access_enabled", "namespaces"."ldap_sync_status", "namespaces"."ldap_sync_error", "namespaces"."ldap_sync_last_update_at", "namespaces"."ldap_sync_last_successful_update_at", "namespaces"."ldap_sync_last_sync_at", "namespaces"."lfs_enabled", "namespaces"."description_html", "namespaces"."parent_id", "namespaces"."shared_runners_minutes_limit", "namespaces"."repository_size_limit", "namespaces"."require_two_factor_authentication", "namespaces"."two_factor_grace_period", "namespaces"."cached_markdown_version", "namespaces"."project_creation_level", "namespaces"."runners_token", "namespaces"."file_template_project_id", "namespaces"."saml_discovery_token", "namespaces"."runners_token_encrypted", "namespaces"."custom_project_templates_group_id", "namespaces"."auto_devops_enabled", "namespaces"."extra_shared_runners_minutes_limit", "namespaces"."last_ci_minutes_notification_at", "namespaces"."last_ci_minutes_usage_notification_level", "namespaces"."subgroup_creation_level", "namespaces"."emails_disabled", "namespaces"."max_pages_size", "namespaces"."max_artifacts_size", "namespaces"."mentions_disabled", "namespaces"."default_branch_protection", "namespaces"."max_personal_access_token_lifetime", "namespaces"."push_rule_id", "namespaces"."shared_runners_enabled", "namespaces"."allow_descendants_override_disabled_shared_runners", "namespaces"."traversal_ids", "namespaces"."organization_id" FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND "namespaces"."parent_id" IS NULL AND "namespaces"."id" IN (SELECT "gitlab_subscriptions"."namespace_id" FROM "gitlab_subscriptions" INNER JOIN "plans" ON "plans"."id" = "gitlab_subscriptions"."hosted_plan_id" WHERE ("gitlab_subscriptions"."trial" = FALSE OR "gitlab_subscriptions"."trial" IS NULL) AND "plans"."name" IN ('bronze', 'silver', 'premium', 'gold', 'ultimate', 'ultimate_trial', 'ultimate_trial_paid_customer', 'premium_trial', 'opensource') AND (end_date > '2024-03-19' OR end_date IS NULL)) ORDER BY "namespaces"."id" ASC LIMIT 1000
https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/27020/commands/84034
Query after
SELECT "gitlab_subscriptions"."id" FROM "gitlab_subscriptions" INNER JOIN "plans" ON "plans"."id" = "gitlab_subscriptions"."hosted_plan_id" WHERE ("gitlab_subscriptions"."trial" = FALSE OR "gitlab_subscriptions"."trial" IS NULL) AND "plans"."name" IN ('bronze', 'silver', 'premium', 'gold', 'ultimate', 'ultimate_trial', 'ultimate_trial_paid_customer', 'premium_trial', 'opensource') AND (end_date IS NULL OR end_date >= '2024-03-19') AND "gitlab_subscriptions"."id" >= 1 ORDER BY "gitlab_subscriptions"."id" ASC LIMIT 1 OFFSET 100
https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/27020/commands/84033
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Edited by Dmitry Gruzd