Loading
Add DuplicateDefaultTrackedContextsCheck consistency check
What does this MR do and why?
Adds DuplicateDefaultTrackedContextsCheck - a consistency check that detects and collapses duplicate default tracked contexts per project.
Problem
Projects can end up with multiple security_project_tracked_contexts records where is_default = true. This causes issues with the VAC (Vulnerabilities Across Contexts) feature.
Solution
When duplicates are found, the check:
- Selects the context matching the project's actual
default_branchas the survivor - If no match, uses the oldest context and updates its
context_name - Updates all references in related tables
- Deletes the duplicate context records
Queries for DB Review
-
Selecting duplicate contexts
Updates
vulnerability_occurrences- Each Batch Min - https://postgres.ai/console/gitlab/gitlab-production-sec/sessions/50966/commands/150920
- Each Batch Max - https://postgres.ai/console/gitlab/gitlab-production-sec/sessions/50966/commands/150921
- Update Query plan - https://postgres.ai/console/gitlab/gitlab-production-sec/sessions/50966/commands/150922
vulnerability_reads- Each Batch Min - https://postgres.ai/console/gitlab/gitlab-production-sec/sessions/50582/commands/150063
- Each Batch Max - https://console.postgres.ai/gitlab/gitlab-production-sec/sessions/50582/commands/150064
- Update Query plan - https://postgres.ai/console/gitlab/gitlab-production-sec/sessions/50582/commands/150065
vulnerability_statisticsvulnerability_historical_statisticssbom_occurrence_refs- EachBatch min - https://postgres.ai/console/gitlab/gitlab-production-sec/sessions/50966/commands/150923
- EachBatch max - https://postgres.ai/console/gitlab/gitlab-production-sec/sessions/50966/commands/150924
- Delete query - https://postgres.ai/console/gitlab/gitlab-production-sec/sessions/50966/commands/150925
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist.
Related issues
Edited by Rushik Subba