Read jobsStatistics queued durations from a CI replica
What does this MR do and why?
CiRunnerConnection.jobsStatistics ran its statement with connection.execute. The load balancer treats execute as an ambiguous query and by default sends it to the CI primary. On the largest group (about 202k group runners), one request costs about 0.84s of CI primary time.
This MR uses select_all. The statement now goes through the load balancer and runs on a replica. A session that already stuck to the primary still reads from the primary.
The result is the percentile of the 100 most recent jobs. Replication lag does not change it in a way that matters.
The SQL does not change. A follow-up MR will limit the query to recent p_ci_builds partitions.
References
- https://gitlab.com/gitlab-org/gitlab/-/work_items/638240
- Parent: https://gitlab.com/gitlab-org/gitlab/-/work_items/638233
Screenshots or screen recordings
Not applicable. There is no UI change.
How to set up and validate locally
- Sign in as an admin on an instance with a licensed
runner_performance_insightsfeature and a CI replica. - Open
/-/graphql-explorerand run:{ runners { jobsStatistics { queuedDuration { p50 p95 } } } } - Confirm the
SELECT EXTRACT('EPOCH' FROM PERCENTILE_CONT ...statement runs on the replica.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.