Skip to content

Conversation

@timgraham
Copy link
Collaborator

No description provided.

def assertAddRemoveIndex(self, editor, model, index):
with self.assertNumQueries(1):
editor.add_index(index=index, model=model)
editor.add_index(index=index, model=model)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be some number of list_search_indexes() queries until the index is ready.

@timgraham timgraham requested a review from WaVEV August 29, 2025 00:25
@timgraham timgraham marked this pull request as ready for review August 29, 2025 00:25
return db_type and field.unique and field.column != "_id"

@staticmethod
def wait_until_index_created(collection, index_name, timeout=60 * 60, interval=0.5):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the timeout 60 times more for creation than deletion? (an hour vs a minute

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe index creation time is ~O(n) (based on collection size) while it seems like dropping an index would probably be a constant time operation. Noah said that creating an index on a large collection "could definitely take over 60 seconds." We didn't receive an answer for the Atlas team on how to choose these values, but my thought is that if we have a user run into either limit, we can increase it further and/or consider adding an AddIndexConcurrently operation, with the caveat that future migration operations would have to be aware that the index may not be ready.

Copy link
Collaborator

@WaVEV WaVEV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@timgraham timgraham merged commit 7e5b229 into mongodb:main Sep 8, 2025
17 checks passed
@timgraham timgraham deleted the search-index-wait branch September 8, 2025 01:01
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.

2 participants