Add enforce_ci_builds_pagination_limit feature flag
What does this MR do and why?
Previously enforcement of keyset pagination for Ci::Build
requests
was not active. This commit adds a feature flag that will allow
enforcement of offset pagination limits to prevent slow database
queries.
Relates to https://gitlab.com/gitlab-com/gl-infra/reliability/-/issues/24660
How to set up and validate locally
- Check out this branch.
- Log in to your GitLab instance.
- In the browser, try to access:
http://gdk.test:3000/api/v4/projects/1/jobs?page=600&per_page=100
. This should return empty results (assuming you don't have thousands of builds). - In
bin/rails console
, runFeature.enable(:enforce_ci_builds_pagination_limit, Project.find(YOUR-PROJECT-ID)
. - Wait 60 seconds or so and repeat step 3. This should result in an error:
{"error":"Offset pagination has a maximum allowed offset of 50000 for requests that return objects of type Ci::Build. Remaining records can be retrieved using keyset pagination."}
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Stan Hu