Repair inconsistent vulnerability data after security scans
What does this MR do and why?
This MR changes vulnerability_consistency_checks from a gitlab_com_derisk flag to an ops flag that is enabled by default.
The flag controls the vulnerability consistency checks (Vulnerabilities::ConsistencyChecks). After a security report ingestion, the checks compare vulnerability_reads with its source data and repair rows that do not match. They also repair related data, for example the has_vulnerabilities setting and missing finding IDs on vulnerability issue links and merge request links.
The checks run at 100% on GitLab.com since 2026-10-19. No job failed because of an error in the checks. When we measured on 2026-10-20, the sec database CPU did not increase. See the rollout issue, #592117.
We do not remove the flag yet, for these reasons:
- The checks are the safety net for turning off the
vulnerability_readsdatabase trigger (#553939). That work is not complete. - Some code paths that write
has_issuesstill need fixes (#632267 (closed)). - When the flag is enabled by default, self-managed and GitLab Dedicated instances also run the checks. An
opsflag lets an administrator stop the checks without a code change if they cause unexpected database load.
Most ops flags are disabled by default. This flag is enabled by default because the checks are a repair that every instance needs, and the flag exists only to stop them.
We remove the flag after we remove the database trigger.
What happens on self-managed and GitLab Dedicated
The checks do not sweep all projects at the same time. A project runs the checks after its next security report ingestion. Each project runs the full sweep at most once every 24 hours. The two tracked-context checks stay behind their own flags, which are disabled by default.
Changes
- Move
ee/config/feature_flags/gitlab_com_derisk/vulnerability_consistency_checks.ymltoee/config/feature_flags/ops/. Settype: ops,default_enabled: true,milestone: '19.6'andgroup: group::vulnerability management, and update the description. - Pass
type: :opsin theFeature.enabled?call inee/lib/vulnerabilities/consistency_checks.rb.
How to disable the checks
On GitLab.com, use ChatOps in #production:
/chatops gitlab run feature set vulnerability_consistency_checks falseOn a self-managed instance, use the Rails console:
Feature.disable(:vulnerability_consistency_checks)On GitLab Dedicated, contact GitLab Support.
The rollout issue (#592117) has a "Disabling the checks" section that is the runbook for this flag.
References
- Rollout issue: #592117
- Turn off the
vulnerability_readsdatabase trigger: #553939 - Remaining
has_issueswriters: #632267 (closed)
How to set up and validate locally
bundle exec rspec ee/spec/lib/vulnerabilities/consistency_checks_spec.rb ee/spec/lib/vulnerabilities/consistency_checks/ ee/spec/workers/vulnerabilities/consistency_check_worker_spec.rb spec/lib/feature/definition_spec.rbResult: 166 examples, 0 failures.