Skip to content

Only refresh indexes that exist

What does this MR do and why?

A support ticket (internal link) had mentioned seeing errors about missing the Commit index in a halted migration. They had recently upgraded from 15.4 to 15.6. The gitlab:elastic:info rake task showed that the current migration running was DeleteOrphanedCommits which is before the commits index is created in MigrateCommitsToSeparateIndex. When looking at the DeleteOrphanedCommits, it was found that the refresh_index method refreshes all indexes when called without an index_name. All indexes may not be created due to pending migrations and I believe it is the root cause of the error.

This MR changes the refresh_index method to skip any indexes not created and adds new specs. Without this fix, customers will have to recreate their index from scratch to get past this error.

Note: The refresh_index method is called with Elasticsearch indexes and aliases and I have tested calling it with both in the rails console to verify that it works.

question: why was this not caught by the migration specs? there is a helper method set_elasticsearch_migration_to which is used to test code before migrations are run, but the method is mocks the data. All migrations are run and marked as completed for each test (regardless of if set_elasticsearch_migration_to is used or not).

Screenshots or screen recordings

N/A

How to set up and validate locally

It's too difficult to get the gdk into a state where the migrations have not run to test this out locally but I trust the new specs!

MR acceptance checklist

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

Edited by Terri Chu

Merge request reports