Skip to content

Backfill zoekt_enabled_namespaces and zoekt_indices

Background

This MR implements the schema design defined here. The plan is to replace Zoekt::IndexedNamespace class and zoekt_indexed_namespaces table with two new classes/tables Search::Zoekt::EnabledNamespace (zoekt_enabled_namespaces and Search::Zoekt::Index (zoekt_indices)

This MR is broken up into multiple iterations

MR What it does
!138992 (merged) Add database migrations and model classes
!140252 (merged) Migrate data and use new models
!140906 (merged) Drop old tables and remove code

What does this MR do and why?

Related to #424121 (closed)

The MR backfills zoekt_enabled_namespaces and zoekt_indices tables and switches all of the code over to use those two new tables in place of zoekt_indexed_namespaces.

The issue describes using a feature flag but I felt that could be avoided if the migrations can run as regular migrations. Having a feature flag switch between the old/new tables would require keeping them both in sync until the flag is removed.

Database timings

I manually ran both migrations in a dblab clone and took timings and left them inline in the diff.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

N/A - no UI changes

How to set up and validate locally

This is an underlying code change and introduces no new behavior. Relying upon specs for most checks.

To test functionality for Zoekt search and index:

  1. checkout the master branch
      git checkout master
  2. enable zoekt in gdk
  3. configure zoekt in your environment
  4. enable it for a namespace
  5. verify that search works for the enabled namespace (if search returns results, indexing is working)
  6. checkout this branch and run the migrations
      git checkout 24121-backfill-zoekt_enabled_namespaces-and-zoekt_indices
      bundle exec rails db:migrate
  7. verify that search works for the enabled namespace (if search returns results, indexing is working)

To test functionality for the Admin Zoekt API

  1. get all zoekt nodes (grab the node id to use in subsequent requests)
      curl --request GET --url http://gdk.test:3000/api/v4/admin/zoekt/shards --header 'Private-Token: <YOUR_TOKEN>'
  2. get zoekt enabled namespaces for a zoekt node
      curl --request GET --url http://gdk.test:3000/api/v4/admin/zoekt/shards/2/indexed_namespaces --header 'Private-Token: <YOUR_TOKEN>'
  3. enable a new namespace via API with search disabled
      curl --request PUT --url http://gdk.test:3000/api/v4/admin/zoekt/shards/2/indexed_namespaces/24 \
      --header 'Content-Type: application/json' \
      --header 'Private-Token: <YOUR_TOKEN>' \
      --data '{ "search": false }'
  4. indexing logs can be viewed with this command
       gdk tail gitlab-zoekt-indexer-development
  5. verify that search works and is NOT using zoekt for the enabled namespace http://gdk.test:3000/search?group_id=24&repository_ref=master&scope=blobs&search=test
  6. enable search in rails console
       ::Search::Zoekt::EnabledNamespace.last.update(search: true)
  7. verify that search works and is using zoekt for the enabled namespace, you should see Exact code search (powered by Zoekt) is enabled http://gdk.test:3000/search?group_id=24&repository_ref=master&scope=blobs&search=test
Edited by Terri Chu

Merge request reports