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

Update index creation before upgrading to Mongo 4.2 #472

Open
MrCreosote opened this issue Nov 4, 2021 · 1 comment
Open

Update index creation before upgrading to Mongo 4.2 #472

MrCreosote opened this issue Nov 4, 2021 · 1 comment

Comments

@MrCreosote
Copy link
Member

Mongo 4.2 change how indexes are built and it appears as though the default behavior is background creation. It's not clear if the client blocks while the index is created. If not, the service could start while the necessary indexes aren't in place which could cause corrupt data and index build fails.

@MrCreosote
Copy link
Member Author

MrCreosote commented Jun 6, 2023

It seems that now the indexes will allow writes while they're building, which means the unique constraint can be violated:
https://www.mongodb.com/community/forums/t/block-until-index-is-created/228390

As such, the index build will need to be updated to

  • createIndex for all the indexes
  • wait for some period of time (1s?)
    • This allows the indexes to be created on a fresh install
  • check that all the indexes are correctly created, and throw an error telling the user to create the missing indexes if not.
  • The alternative is to sit there and poll until the indexes are built, but that seems like a waste of time - better to just shut down.

@MrCreosote MrCreosote changed the title Understand index creation blocking before upgrading to Mongo 4.2 Update index creation before upgrading to Mongo 4.2 Jun 6, 2023
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

No branches or pull requests

1 participant