Fix Gitaly N+1 in /api/v4/project/:id/jobs (behind FF)
What does this MR do and why?
There's a gitaly N+1 in the jobs API. The commit field is retrieved
via Commit.lazy, but only at serialization time, which forces the
eager evaluation of each individual commit. We fix this by evaluating
the commit method of each build in the paginated result set prior to
serialization.
Given the criticality of the endpoint, this fix is behind the feature
flag fix_jobs_api_gitaly_n_plus_1 (disabled by default), to derisk the
rollout.
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
See the tests for an example.
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.
Edited by Hordur Freyr Yngvason