Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use suffixed index names by default to prevent alias creation conflicts #973

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dmeremyanin
Copy link

@dmeremyanin dmeremyanin commented Nov 24, 2024

Synopsis

Recently, we encountered a problem during index reset operations where a race condition could cause an alias creation failure. The issue arises when:

  1. An index (e.g., users) is being reset.
  2. The reset task creates a new suffixed index (e.g., users_<timestamp-suffix>) and starts the import process.
  3. Once the import is finished, the reset task deletes the old index (here).
  4. The reset task attempts to create an alias (e.g., users) pointing to the new suffixed index (here).
  5. The problem occurs: There is a small time window between the old index deletion and the alias creation, during which another background job could recreate the unsuffixed users index. This results in a conflict when trying to create the alias, as both an index and an alias cannot share the same name.
  6. The result: The alias creation fails, and no data is available in the index – the old index is deleted, and the new suffixed index is not aliased.

Solution

To prevent this issue, I updated the index creation logic to always use suffixed index names and unsuffixed aliases by default, not just after an index reset. This ensures that the alias conflict issue caused by the recreation of the old unsuffixed index is avoided.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the changelog if the new code introduces user-observable changes. See changelog entry format for details.

@dmeremyanin dmeremyanin requested a review from a team as a code owner November 24, 2024 07:59
@dmeremyanin
Copy link
Author

@toptal-anvil ping reviewers

Updated index creation logic to use a suffixed index name (e.g., `users_<timestamp-suffix>`) by default.

Previously, during index reset, the old index (e.g., `users`) was deleted, and a new suffixed index (e.g., `users_<timestamp-suffix>`) was created and aliased to the old index name. This caused a race condition, where another job could recreate the unsuffixed `users` index before the alias was applied, leading to a conflict when trying to create the alias.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant