Allow specifying single index to reindex when using reindex feature
What does this MR do and why?
This MR introduces a new field called targets
to the elastic_reindexing_tasks
table to allow reindexing specific indices using the Zero-downtime reindexing feature.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Migrations
❯ VERSION=20221006141145 bin/rails db:migrate:up:main
main: == 20221006141145 AddTargetsToElasticReindexingTasks: migrating ===============
main: -- add_column(:elastic_reindexing_tasks, :targets, :text, {:array=>true})
main: -> 0.0012s
main: == 20221006141145 AddTargetsToElasticReindexingTasks: migrated (0.0014s) ======
❯ VERSION=20221006141145 bin/rails db:migrate:down:main
main: == 20221006141145 AddTargetsToElasticReindexingTasks: reverting ===============
main: -- remove_column(:elastic_reindexing_tasks, :targets, :text, {:array=>true})
main: -> 0.0022s
main: == 20221006141145 AddTargetsToElasticReindexingTasks: reverted (0.0041s) ======
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Enable Advanced Search
- Create a new reindexing task with only one class. For example
Elastic::ReindexingTask.create!(targets: %w[Repository])
- Trigger
ElasticClusterReindexingCronWorker.new.perform
repeatedly - Check out the reindexing progress via
Elastic::ReindexingTask.current
or/admin/application_settings/advanced_search
- Ensure that you have a new
gitlab-development
index viacurl http://localhost:9200/_cat/indices
- After reindexing is completed you should notice that
Elastic::ReindexingTask.last.state
has changed tosuccess
- Ensure that
curl http://localhost:9200/_cat/aliases/gitlab-development
points to newly created index and search still works
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #323293 (closed)
Edited by Dmitry Gruzd