-
Notifications
You must be signed in to change notification settings - Fork 768
SOLR-17670: Fix unnecessary memory allocation caused by a large reRankDocs param #3181
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
Merged
Conversation
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
risdenk
requested changes
Feb 13, 2025
solr/core/src/test/org/apache/solr/search/TestRerankOnSolrCloud.java
Outdated
Show resolved
Hide resolved
risdenk
approved these changes
Feb 14, 2025
dsmiley
approved these changes
Feb 14, 2025
I'll be merging this nice fix into 9.8.1 |
Thanks so much, David! |
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.
https://issues.apache.org/jira/browse/SOLR-17670
Description
For a query containing re-ranking, such as:
{
"start": "0",
"rows": 10,
"fl": "ID,score",
"q": ":",
"rq": "{!rerank reRankQuery='{!func} 100' reRankDocs=1000000000 reRankWeight=2}"
}
The current execution logic is as follows:
During the retrieval in phase 1 (using q), a TopScoreDocCollector is created. Underneath, this creates a PriorityQueue which contains an Object[]. The length of this Object[] continuously increases with reRankDocs without any limit.
On my local test cluster with limited JVM memory, this can even trigger an OOM, causing the Solr node to crash. I can also reproduce the OOM situation using the SolrCloudTestCase unit test.
Solution
I think limiting the length of the Object[] array using searcher.getIndexReader().maxDoc() at ReRankCollector would resolve this issue. This way, when reRankDocs exceeds maxDoc, memory allocation will not continue to increase indefinitely.
Tests
TestRerankOnSolrCloud will reproduce the OOM situation without my fix.
Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.