Backport of 'Cap the commit page pipelines badge count at 1,000+' into 19.4
What does this MR do and why?
Backport of !264101 (merged) into 19.4. Cherry-pick of b048b21801ede975a9dc8bf3df526d1fcedc75a8.
A commit can collect tens of thousands of pipelines, for example on a project that triggers pipelines for other projects through schedules. On those commits the Pipelines tab badge on the commit page runs an unbounded COUNT(*) over every pipeline of the sha, which costs as much as the unbounded newest-pipeline lookup.
This change switches the badge to limited_counter_with_delimiter, which wraps the count in LIMIT 1001 and shows 1,000+ above the cap.
Two files. No migration, no schema change, no new query shape. The only user-visible difference is that a commit with more than 1,000 pipelines shows 1,000+ on the badge.
Why backport
Reported by a GitLab Dedicated customer whose commit pages return 500 on an affected project. The tenant runs 19.4.3 and is scheduled to 19.4.5, so it cannot receive this from master. A matching backport into 19.5 is raised in !267755 (merged) to cover the tenant's upgrade path.
- Zendesk 752368
- gitlab-com/request-for-help#5424
Cherry-pick notes
app/views/projects/commit/_ci_menu.html.haml is byte-identical to master on this branch, so that hunk applies unchanged.
spec/views/projects/commit/show.html.haml_spec.rb needed the hunk re-anchored. The patch's trailing context on master reads let(:merge_request) { build_stubbed(...) }, while this branch still reads let(:merge_request) { create(...) }, so an unmodified cherry-pick reports a conflict there. The new describe 'pipelines tab badge' block is self-contained and does not depend on that line, so it was inserted ahead of the context 'in the context of a merge request' block and this branch keeps its own create(...) line. The added test content is identical to the one on master.
Squash is disabled so the Changelog: performance trailer and the (cherry picked from commit ...) line survive the merge.
Scope
This caps the badge count only. The commit page's main pipeline lookup, Ci::CommitWithPipeline#last_pipeline, is still unbounded and sits in the draft !263784, so this change on its own does not make the commit page load for the reporting customer. It removes one of the two expensive queries on that page.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
- This MR is backporting a bug fix, documentation update, or spec fix, previously merged in the default branch.
- The MR that fixed the bug on the default branch has been deployed to GitLab.com (not applicable for documentation or spec changes).
- The MR title is descriptive (e.g. "Backport of 'title of default branch MR'"). This is important, since the title will be copied to the patch blog post.
- Required labels have been applied to this merge request
- severity label and bug subtype labels (if applicable)
- If this MR fixes a bug that affects customers, the customer label has been applied.
- This MR has been approved by a maintainer (only one approval is required).
- Ensure the
E2E Omnibus GitLab EEpipeline (triggered by thee2e:test-on-omnibus-eejob) has succeeded. If it has failed (or shows warnings), investigate the failures. If you determine the failures are unrelated, you may proceed. If you need assistance investigating, request help in the #s_developer_experience Slack channel to confirm the failures are unrelated to the merge request.
Note to the merge request author and maintainer
If you have questions about the patch release process, please:
- Refer to the patch release runbook for engineers and maintainers for guidance.
- Ask questions on the
#releasesSlack channel (internal only). - Once the backport has been merged, the commit changes will be automatically deployed to a release environment that can be used for manual validation. See after merging runbook for details.
cc @tigerwnz