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 |
|
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:
- checkout the master branch
git checkout master
- enable zoekt in gdk
- configure zoekt in your environment
- enable it for a namespace
- verify that search works for the enabled namespace (if search returns results, indexing is working)
- checkout this branch and run the migrations
git checkout 24121-backfill-zoekt_enabled_namespaces-and-zoekt_indices bundle exec rails db:migrate
- verify that search works for the enabled namespace (if search returns results, indexing is working)
To test functionality for the Admin Zoekt API
- 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>'
- 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>'
- enable a new namespace via API with
search
disabledcurl --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 }'
- indexing logs can be viewed with this command
gdk tail gitlab-zoekt-indexer-development
- 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
- enable search in rails console
::Search::Zoekt::EnabledNamespace.last.update(search: true)
- 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