Repository navigation
Fix panic on query with huge limit - #5484
Merged
Merged
Conversation
Prevents an allocation failure and panic if a user specifies a huge search limit.
timvisee
force-pushed
the
fix-panic-on-huge-query-limit
branch
from
November 19, 2024 16:44
48237dd to
f2a90a9
Compare
agourlay
reviewed
Nov 19, 2024
| use segment::types::{PointIdType, ScoredPoint, SeqNumberType}; | ||
|
|
||
| /// Avoid excessive memory allocation and allocation failures on huge limits | ||
| const LARGEST_REASONABLE_ALLOCATION_SIZE: usize = 1_048_576; |
Member
There was a problem hiding this comment.
I think a lower value should be enough if we want to protect ourselves.
Something like 8,192
generall
approved these changes
Nov 19, 2024
timvisee
added a commit
that referenced
this pull request
Dec 9, 2024
* Limit maximum preallocation on search results aggregator hash set Prevents an allocation failure and panic if a user specifies a huge search limit. * Prevent overflow on fixed length priority queue limit with u64::MAX * Fix overflow with high limit in search API * Add two basic tests covering high search limit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #5483
Here we started to preallocate memory in the search result aggregator based on the user provided limit. If a user provides a huge limit it will panic due to an allocation failure.
This PR fixes the problem by limiting the size of preallocating to one million items, exactly like
FixedLengthPriorityQueuedoes. I'm not entirely sure if one million is reasonable here, and it might be too big. Lets discuss here what we think may be reasonable.I've also fixed a limit overflow in
FixedLengthPriorityQueueif alimitofu64::MAXis given, and an overflow in search.All Submissions:
devbranch. Did you create your branch fromdev?