Skip to content

Migration to fix wrong values of label_ids in epics index

Ravi Kumar requested to merge 424198-migration-fix-label_ids-in-epics into master

What does this MR do and why?

When we removed the labels from epics, there was a bug not updating the label_ids in the epics index. This MR is to reindex all the epics which don't have new SCHEMA_VERSION = 23_10. The schema_version with 2310 is set after the underlying bug gets fixed.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  • Ensure elasticsearch is enabled
  • For a fresh test, create a new group. Create an epic in this group.
  • Update the schema_version and label_ids for this epic in the elastic by running the following command. Replace the group_id with the one you have just created.
curl -XPOST "http://localhost:9200/gitlab-development-epics/_update_by_query" -H "kbn-xsrf: reporting" -H "Content-Type: application/json" -d'
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "group_id": group_id
          }
        }
      ]
    }
  },
  "script": {
    "source": "ctx._source.schema_version = 2309;ctx._source.label_ids=[0]"
  }
}' | json_pp
  • Ensure on Elastic that the epic has been updated successfully by running the following command. Verify that the schema_version is 2309 and label_ids is [0]. Replace the group_id with the one you just created.
curl -XGET "http://localhost:9200/gitlab-development-epics/_search" -H "kbn-xsrf: reporting" -H "Content-Type: application/json" -d'
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "group_id": group_id
          }
        }
      ]
    }
  }
}' | json_pp
  • Open the rails console
bundle exec rails c
  • Run the following command
Elastic::DataMigrationService[20231016162120].send(:migration).migrate
  • And then again run the above XGET curl command and ensure the schema_version is 2310 and the label_ids is an empty array. It might take a few seconds to reflect the changes. If it takes longer than 1 minute then restart the rails-background-jobs and check again.
gdk restart rails-background-jobs

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Run time

34 minutes

[8] pry(main)> documents_count = 308639
=> 308639
[9] pry(main)> throttle_delay = 1.minute
=> 1 minute
[10] pry(main)> batch_size = 9_000
=> 9000
[11] pry(main)> ((documents_count / batch_size) * throttle_delay)
=> 34 minutes

Related to #424198 (closed)

#427593 (closed)

Edited by Ravi Kumar

Merge request reports

Loading