Repository navigation
Conversation
…prefetch cache - Reject non-numeric or negative preFetchDocs with BAD_REQUEST instead of a NumberFormatException / NegativeArraySizeException (500). - Tolerate a null QParser in the constructor; use the default limit. - Clear cachedValuesById on every setContext so a context without a DocList can't serve values cached against an earlier searcher. - Add TestValueSourceAugmenterPrefetchLimit, checking function values on both sides of the prefetch limit, preFetchDocs=0, invalid values, and the stale-cache case. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
|
Looks good. One suggestion: strengthen the cache test by using a replacement searcher with a different value for the same document ID. |
Use numdocs(), whose value for the same docid differs once a document is added, so a stale cache would return a provably wrong value. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
|
Good call. The test now caches Written with Claude Code (Opus 5.5) |
- Clear cachedValuesById before any setContext step that can throw. - testNullQParserUsesDefault now checks the default limit of 1000 is applied. - Trim the changelog entry to the user-visible change. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
|
@nick-boss-tech - can you take another look when you have a chance? thanks! |
Index across several segments (NoMergePolicyFactory, a commit every 300 docs) and add testOutOfDocIdOrderAcrossSegments: results sorted in reverse docid order, with a forward-only docValues function, on both sides of the prefetch limit. The prefetch must sort the docids and switch segments at each docBase, or the per-segment FunctionValues reject out-of-order docs. Also use NUM_DOCS throughout instead of MAX_PREFETCH_SIZE + 10. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
|
It looks good now. Thanks! |
… honored - An IOException during prefetch now reports the docid being computed, as the per-doc fallback already does. - The preFetchDocs=2000 and preFetchDocs=0 tests now check the cache size, since the on-demand fallback produces the same output as the cache. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
dsmiley
left a comment
There was a problem hiding this comment.
Thanks for reporting & fixing this!
| private static int parseMaxPrefetchSize(QParser qparser) { | ||
| String raw = qparser != null ? qparser.getParam(PREFETCH_DOCS_PARAM) : null; | ||
| if (raw == null) { | ||
| return DEFAULT_MAX_PREFETCH_SIZE; | ||
| } | ||
| try { | ||
| int value = Integer.parseInt(raw); | ||
| if (value >= 0) { | ||
| return value; | ||
| } | ||
| } catch (NumberFormatException e) { | ||
| // fall through | ||
| } | ||
| throw new SolrException( | ||
| SolrException.ErrorCode.BAD_REQUEST, | ||
| PREFETCH_DOCS_PARAM + " must be a non-negative integer: " + raw); | ||
| } |
There was a problem hiding this comment.
The standard approach is to use org.apache.solr.common.params.SolrParams#getInt(java.lang.String, int) to avoid repeating all this awkward code everywhere we get an int from params. You can get the params from QParser to call it.
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
https://issues.apache.org/jira/browse/SOLR-18620
Description
Follow-up to SOLR-17775. The
preFetchDocsparam and the prefetch cache inValueSourceAugmenterhave a few rough edges:preFetchDocs=abcthrows aNumberFormatExceptionandpreFetchDocs=-1throws aNegativeArraySizeException(fromnew int[-1]insetContext). Both surface as 500s instead of 400s.qparser.getParam(...), so passing a nullQParser(previously fine, since it was only stored) throws an NPE.setContextgets a context with no DocList, it returns before replacingcachedValuesById, so a reused transformer can serve values cached against an earlier searcher.Solution
preFetchDocsin a helper that throwsSolrException(BAD_REQUEST)for non-numeric or negative values, and falls back to the default of 1000 when the QParser is null.cachedValuesByIdat the start of everysetContext, before the early return.Developed with Claude Code (Opus 5.5) assisting; I reviewed the changes.
Tests
Added
TestValueSourceAugmenterPrefetchLimit(the SOLR-18181 version of this test is onbranch_9xbut notmain), with assertions that every returned doc has the function value and that it equals the doc'sid, below and above the prefetch limit. New cases coverpreFetchDocs=0, invalid values (abc,-1) returning 400, a null QParser falling back to the default limit of 1000, and a stale-cache case: values cached from one searcher, then a document added and a replacement searcher opened, thensetContextwith no DocList must return the new searcher's value for the same docid.Ran
TestValueSourceAugmenterPrefetchLimit,ReturnFieldsTest,TestPseudoReturnFields, and./gradlew :solr:core:check -x test.Checklist
mainbranch../gradlew check.🤖 Generated with Claude Code