-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
Gracefully handle search index exceptions if possible #2671
Conversation
hi @alcaeus, I would be happy to help, but it seems I cannot test your PR since my app requires
|
Ah, sorry, it's been a while since I've done this. You can use an inline alias to require the package: That should fix the issue you encountered. |
hey thanks, I just learnt something! 😊 Now I have required your PR, I still have the same error:
with exit code 255 BTW, we're using mongo 4.4 |
Ah, that's probably the reason why you're getting a different message. Thanks for taking a look, I'll update this PR after some more testing. |
@nikophil I've updated the code to also handle server versions where |
@@ -44,6 +46,7 @@ final class SchemaManager | |||
private const GRIDFS_CHUNKS_COLLECTION_INDEX = ['filename' => 1, 'uploadDate' => 1]; | |||
|
|||
private const CODE_SHARDING_ALREADY_INITIALIZED = 23; | |||
private const CODE_COMMAND_NOT_SUPPORTED = 115; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there are no consts anywhere in drivers? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope :)
With 2.8.1 this is still causing us a problem in TbbcMoneyBundle. I think the circumstances are an index exists (not a search index), then the schema is dropped. It tries to run a We are dropping the schema with |
@mustanggb I just ran the tests for TbbcMoneyBundle locally. With MongoDB 7.0.9, I was able to reproduce the failures using ODM 2.8.0, but using 2.8.1 fixes the tests. Removing the constraint in #180 works on my machine - could you please give it another look and share the exception if one happens? I noticed that the command invocation uses a |
Looks like it's saying |
For me also the error is |
I've released 2.8.2 with a fix for this. Sorry for the delay here. |
Confirming this is working for us now. |
Summary
#2630 introduces support for managing search indexes in the schema manager. However, the logic does not correctly handle cases when the server does not support search indexes. This PR adds more graceful handling in cases where no search index changes are necessary. Here's a list of the changes:
listSearchIndexes
command will no longer cause an exception. If a class has search indexes, the old behaviour still applieslistSearchIndexes
command no longer throws an exception, since there are no search indexes to be removed.We specifically check for error code 115 (CommandNotSupported) and check the exception message to make sure that it's actually an issue with the search index command, as there are no good ways to check for search index support.