Skip to content

Backfill resolved_at, dismissed_at on vulnerability ES index

What does this MR do and why?

Backfills resolved_at, dismissed_at fields on the vulnerability ES index.

Screenshots or screen recordings

Before After
Screenshot_2025-09-10_at_6.49.24_PM Screenshot_2025-09-10_at_6.51.59_PM

How to set up and validate locally

  1. Apply this patch
diff --git a/ee/lib/search/elastic/references/vulnerability.rb b/ee/lib/search/elastic/references/vulnerability.rb
index 0c3d9bcf6096..a4703fa1f6e5 100644
--- a/ee/lib/search/elastic/references/vulnerability.rb
+++ b/ee/lib/search/elastic/references/vulnerability.rb
@@ -7,7 +7,7 @@ class Vulnerability < Reference
         include Search::Elastic::Concerns::DatabaseReference
         include ::Gitlab::Utils::StrongMemoize

-        SCHEMA_VERSION = 25_26
+        SCHEMA_VERSION = 25_36
         DOC_TYPE = 'vulnerability'
         INDEX_NAME = 'vulnerabilities'
  1. Start Rails console with SASS GITLAB_SIMULATE_SAAS=1 bundle exec rails console

  2. Run the manual bookkeeping command

Vulnerabilities::Read.all.each { |v| ::Elastic::ProcessBookkeepingService.track!(Search::Elastic::References::Vulnerability.new(v.vulnerability_id, "group_#{v.project.namespace.root_ancestor.id}")) }
  1. Run process bookkeeping multiple times till the results are shown as [0, 0].
Elastic::ProcessBookkeepingService.new.execute
  1. Run the query and verify that the counts shows up and not 0.
GET /gitlab-development-vulnerabilities/_count
{
  "query": {
    "term": {
      "schema_version": 2526
    }
  }
}
  1. Reset the above patch and change to SCHEMA_VERSION = 25_36. Restart rails console GITLAB_SIMULATE_SAAS=1 bundle exec rails console and gdk restart rails-background-jobs.

  2. Run the migration and initialbookkeeping service multiple times till the results show [0, 0].

Elastic::DataMigrationService[20250910180829].migrate
::Elastic::ProcessInitialBookkeepingService.new.execute
  1. Verify with the below query that there are no older schema records and the count returns 0.
GET /gitlab-development-vulnerabilities/_count
{
  "query": {
    "term": {
      "schema_version": 2526
    }
  }
}

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.

Related to #563391 (closed)

Edited by Bala Kumar

Merge request reports

Loading