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

MB-60274: Set an upper bound for K value for KNN queries #1953

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

CascadingRadium
Copy link
Member

JIRA

https://issues.couchbase.com/browse/MB-60274

Description

Currently, the value of K in KNN queries is only lower-bounded to 1 without an upper limit. This lack of an upper boundary leads to issues where users setting K to extremely high values, such as 999999999, cause a crash due to excessive memory allocation exceeding 8GB.

To address this issue, this commit introduces an upper bound check for variable K. Setting an upper limit of 10000 for K prevents excessive memory demands, capping the maximum memory requirement at a reasonable 120KB. This change ensures system stability by preventing memory overflow issues caused by excessively high K values."

@CascadingRadium
Copy link
Member Author

With this upper bound, we can change the datatype of K from int64 to int which would simplify some code downstream where type conversions are made.
can i do that

@abhinavdangeti abhinavdangeti merged commit 80aa03f into unstable Jan 5, 2024
9 checks passed
@abhinavdangeti abhinavdangeti deleted the setMaxK branch January 5, 2024 15:38
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