feat(mango
): add allow_fallback
for user-specified indexes on _find
#4792
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an alternative to #4710 based on the results of the related discussion.
It is not always beneficial for the performance if the Mango query planner tries to assign an index to the selector. User-specified indexes may save the day, but since they are only hints for the planner, fallbacks may still happen.
Introduce the
allow_fallback
flag which can be used to tell if falling back to other indexes is acceptable when an index is explicitly specified by the user. When set tofalse
, give up on planning and return an HTTP 400 response right away. This way the user has the chance to learn about the requested but missing index, optionally create it and try again.By default, fallbacks are allowed to maintain backwards compatibility. It is possible to set
allow_fallback
totrue
but currently it coincides with the default behavior hence becomes a no-op in practice.Fixes #4511
Testing recommendations
The changes could be verified by the following commands:
This is a non-breaking change, so there should be no observable difference in the behavior for the users. When
allow_fallback
is set tofalse
anduse_index
is set to some index, it may return HTTP 400 depending on the suitability of the given index.Checklist
src/docs
folder