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_reads database trigger (#553939). That work is not complete.
  • Some code paths that write has_issues still need fixes (#632267 (closed)).
  • When the flag is enabled by default, self-managed and GitLab Dedicated instances also run the checks. An ops flag 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.yml to ee/config/feature_flags/ops/. Set type: ops, default_enabled: true, milestone: '19.6' and group: group::vulnerability management, and update the description.
  • Pass type: :ops in the Feature.enabled? call in ee/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 false

On 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

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.rb

Result: 166 examples, 0 failures.

Merge request reports

Loading
Loading