Read auto-remediation dismissals from the remediations table
What does this MR do and why?
Today a dismissed version is recovered by parsing the title of a closed merge request. That breaks on a title it cannot parse, and disappears entirely if the merge request is deleted. This MR reads the persisted row instead, behind the feature flag dependency_management_persisted_remediations, which defaults to off.
The title-parsing check stays underneath as a fallback. Rows only exist for remediations proposed since the table shipped, so without it every dismissal predating this would resurface at once. It comes out in a follow-up once those have aged out.
Behaviour when the flag is on:
| Behaviour | Why |
|---|---|
| A dismissal is decided by the remediated dependency alone, not every dependency in the updater output | The others are packages the updater moved to land the fix, and were never proposed on their own |
| The row is also matched on the installed version | A dismissal recorded against an older install must not suppress proposals after the dependency has moved on |
SchedulerService only consults the table on reschedule runs, where no candidate version exists yet, so it skips on a dismissal for that location without comparing versions |
Initial runs still re-evaluate, so a newer version resurfaces as before |
The service passes the occurrence it records against into the checker, so the reader looks up the same row the writer wrote. If that occurrence can't be resolved, no row is read and only the title check applies.
Only a dismissed row suppresses a proposal. A close by the bot itself, a close with no recorded closer, or a close caused by deleting the source branch all leave the row untouched, so it still reads as open and the bump is proposed again. Reopening a merge request withdraws a dismissal and returns the row to open.
Database
One new query, Remediation.for_occurrence: once per proposal, and once per occurrence on reschedule runs. It hits the unique index on all five columns, 0.15 ms on gitlab-production-sec (35 rows today, plan).
Query
SELECT "dependency_management_remediations".* FROM "dependency_management_remediations"
WHERE "dependency_management_remediations"."project_id" = 278964
AND "dependency_management_remediations"."purl_type" = 3
AND "dependency_management_remediations"."package_name" = 'rails'
AND "dependency_management_remediations"."input_file_path" = 'Gemfile.lock'
AND "dependency_management_remediations"."current_version" = '7.0.8'
LIMIT 1Plan
Limit (cost=0.14..3.17 rows=1 width=180) (actual time=0.112..0.112 rows=0 loops=1)
Buffers: shared hit=6 read=1
-> Index Scan using idx_dm_remediations_on_project_purl_package_path_and_version on public.dependency_management_remediations (cost=0.14..3.17 rows=1 width=180) (actual time=0.110..0.110 rows=0 loops=1)
Index Cond: ((project_id = 278964) AND (purl_type = 3) AND (package_name = 'rails'::text) AND (input_file_path = 'Gemfile.lock'::text) AND (current_version = '7.0.8'::text))
Index Searches: 1
Buffers: shared hit=6 read=1
Planning Time: 0.504 ms
Execution Time: 0.149 msReferences
Related to #603968
How to set up and validate locally
With a remediation merge request open and its row present:
Feature.enable(:dependency_management_persisted_remediations)Close the merge request as any user other than the bot, delete it, then re-run the pipeline. No new merge request is created, which is the case the merge request history check cannot handle.
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.