Alert Management - getAlertsCount graphQL query timeout
Summary
A gitlab.com customer has reported frequent errors when loading the Monitor,Alerts page for one of their projects.
No alert details are displayed, and the message There was an error displaying the alerts. Confirm your endpoint's configuration details to ensure alerts appear.
is displayed.
When the page does load the alert counts indicate are approx 42000 alerts in total.
The query that is timing out after 15 seconds is:
/*application:web,correlation_id:8ceaeadad3abdb1a50fb68bda2c0d032,endpoint_id:GraphqlController#execute,db_config_database:gitlabhq_production,db_config_name:main_replica*/
SELECT COUNT(*) AS "count_all", "alert_management_alerts"."status" AS "alert_management_alerts_status"
FROM "alert_management_alerts"
WHERE "alert_management_alerts"."project_id" = $1
AND "alert_management_alerts"."domain" = $2
GROUP BY "alert_management_alerts"."status"
The alert_management_alerts
table does not appear to have an index in place to optimize the performance of this query.
Details of the project which produces the error can be found in the support ticket (internal link).
Steps to reproduce
Browse to Alerts page for a project which has 40,000+ alerts.
Example Project
What is the current bug behavior?
Alerts page frequently errors due to query timeout.
What is the expected correct behavior?
Alerts page should not error.
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: \\\`sudo gitlab-rake gitlab:env:info\\\`) (For installations from source run and paste the output of: \\\`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production\\\`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of: \`sudo gitlab-rake gitlab:check SANITIZE=true\`) (For installations from source run and paste the output of: \`sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true\`) (we will only investigate if the tests are passing)