Use sharding_key_id to replace Ci::Runner.owner_project implementation
What does this MR do and why?
This MR takes advantage of the Cells 1.0 work which introduced a sharding_key_id
column in ci_runners
, so we can leverage that field to return the owner
for a runner (not just the owner_project
). It also avoids joining with the ci_runner_projects
table to find the owner project.
References
Please include cross links to any resources that are relevant to this MR This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
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.
n/a
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
I'm relying on test coverage to ensure that the functionality doesn't change.
Database query plans
::Ci::Runner.project_type.id_in().pluck(:id, :sharding_key_id)
https://console.postgres.ai/gitlab/gitlab-production-ci/sessions/33175/commands/102485
SELECT "ci_runners"."id", "ci_runners"."sharding_key_id"
FROM "ci_runners"
WHERE "ci_runners"."runner_type" = 3
AND "ci_runners"."id" IN (<100 runner IDs>)
Time: 17.209 ms
- planning: 1.362 ms
- execution: 15.847 ms
- I/O read: 14.977 ms
- I/O write: 0.000 ms
Shared buffers:
- hits: 374 (~2.90 MiB) from the buffer pool
- reads: 30 (~240.00 KiB) from the OS file cache, including disk I/O
- dirtied: 29 (~232.00 KiB)
- writes: 0