Skip to content

Add reindexing column in ActiveContext Code

What does this MR do and why?

We need to be able to handle force-pushes and force-reindex in general.

We settled on the solution to introduce a reindexing flag and use this flag as such:

  1. During a forced reindexing (force-pushes or force-reindex), mark updated documents in the given project as reindexing=true
  2. After all the documents have been updated, delete all documents in the given project with reindexing=false - meaning this document was not "found" during reindexing
  3. Update all documents in the given project to reindexing=false - meaning we have moved back to the normal non-reindex mode

For further details on the solution, refer to gitlab-elasticsearch-indexer!704 (comment 2687184492).

Related issue: [Code indexing pipeline] Handle force_reindex (gitlab-elasticsearch-indexer#172 - closed)

Related implementation changes:

References

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. Re-set the gitlab_active_context_code_0 index:

    ActiveContext.adapter.client.client.indices.delete(index: "gitlab_active_context_code_0")
  2. Re-migrate the ActiveContext Code collection migrations:

    ActiveContext::Migration::Dictionary.migrations.each do |migration_class|
      migration_class.new.migrate!
    end
  3. Verify that the gitlab_active_context_code_0 now has the reindexing field:

    Screenshot_2025-08-15_at_13.09.52

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.

Edited by Pam Artiaga

Merge request reports

Loading