nick-boss-tech opened a new pull request, #5216:
URL: https://github.com/apache/solr/pull/5216

   🤖 *AI text below* 🤖 *(reviewed by Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-17840
   
   ## What happens today
   
   **When a query exceeds its time limit, hits that were already selected are 
thrown away instead of returned as partial results.** The ticket's ignored LTR 
regression shows it: at the base, enabling the test gives `mismatch: '4'!='0'` 
on `response/numFound` for `timeAllowed=800` in 
[TestLTRQParserPlugin](https://github.com/apache/solr/blob/5b2ac4dea21a7c86e31e2ba0cea58c262dc558c8/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTRQParserPlugin.java#L144-L176).
 
[QueryComponent](https://github.com/apache/solr/blob/5b2ac4dea21a7c86e31e2ba0cea58c262dc558c8/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java#L1861-L1869)
 returns on the limit before the selected results are published.
   
   ## What this change does
   
   **Allowed partial hits survive; disallowed ones are omitted.** 
[QueryComponent](https://github.com/apache/solr/blob/325cfbae9873276bd88c2916c786c0fa66502108/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java#L1861-L1869)
 evaluates the limit before publication and publishes the selected results only 
when partial results are allowed; with `partialResults=false` the response 
stays empty and is marked `omitted`. During response streaming, an 
already-selected document fetch may finish after a limit trips, and only when 
partial results are allowed; the checks in 
[DocsStreamer](https://github.com/apache/solr/blob/325cfbae9873276bd88c2916c786c0fa66502108/solr/core/src/java/org/apache/solr/response/DocsStreamer.java#L121-L137)
 and 
[QueryLimits](https://github.com/apache/solr/blob/325cfbae9873276bd88c2916c786c0fa66502108/solr/core/src/java/org/apache/solr/search/QueryLimits.java#L103-L123)
 keep every other limit in force, including for transformers and subqueries.
   
   ## Proof
   
   **Both failure modes are reproduced without the fix, and the focused suites 
pass with it.** Verified 2026-10-23 at the gated tree (this head is a squash of 
that tree, byte-identical), seed `1BB02D3762B56611`:
   
   - 
[TestLTRQParserPlugin](https://github.com/apache/solr/blob/325cfbae9873276bd88c2916c786c0fa66502108/solr/modules/ltr/src/test/org/apache/solr/ltr/TestLTRQParserPlugin.java#L144-L176):
 at the base with the ignore removed, 1 of 1 failed (`4` vs `0`); at the head, 
15 of 15 pass.
   - 
[TestQueryComponentPartialResults](https://github.com/apache/solr/blob/325cfbae9873276bd88c2916c786c0fa66502108/solr/core/src/test/org/apache/solr/handler/component/TestQueryComponentPartialResults.java#L67-L155):
 3 of 3 pass; the disallowed-partials case failed on the prior code with 
"Disallowed partial results must not be published".
   - 
[TestPartialResultsFetch](https://github.com/apache/solr/blob/325cfbae9873276bd88c2916c786c0fa66502108/solr/core/src/test/org/apache/solr/response/TestPartialResultsFetch.java#L47-L242)
 7 of 7, 
[TestQueryLimits](https://github.com/apache/solr/blob/325cfbae9873276bd88c2916c786c0fa66502108/solr/core/src/test/org/apache/solr/search/TestQueryLimits.java#L114-L160)
 2 of 2, 
[ComponentStageLimitsTest](https://github.com/apache/solr/blob/325cfbae9873276bd88c2916c786c0fa66502108/solr/core/src/test/org/apache/solr/search/ComponentStageLimitsTest.java#L95-L215)
 4 of 4. Total 31 passed, none skipped.
   - Tidy is clean, Error Prone compilation passes, and `:solr:core:check 
:solr:modules:ltr:check -x test` passes.
   
   ## Limits
   
   - The fetch exemption is deliberately narrow: it lets one already-selected 
document finish fetching when partial results are allowed and a limit has 
already tripped. It does not apply when `partialResults=false`, and a limit 
first observed during the fetch still stops the response.
   - The ticket title ("LTR is broken after Lucene 10 upgrade") covers more 
than this PR. This change fixes the timeout path the ignored regression 
exercises; it does not claim the rest of the Lucene 10 LTR fallout.
   
   ## Checklist
   
   - [x] I have reviewed the guidelines for How to Contribute and my code 
conforms to the standards described there to the best of my ability.
   - [x] I have created a Jira issue and added the issue ID to my pull request 
title. SOLR-17840
   - [x] I have given Solr maintainers access to contribute to my PR branch.
   - [x] I have developed this patch against the `main` branch.
   - [ ] I have run `./gradlew check`. **Not run in full:** the module checks 
listed under Proof pass at the head.
   - [x] I have added tests for my changes.
   - [ ] I have added documentation for the Reference Guide. **Not 
applicable:** no user-facing behavior is added; timeout and partial-results 
semantics are unchanged in shape.
   - [x] I have added a changelog entry.
   
   *AI-generated description. Nick Shanin directed the work and takes 
responsibility for this contribution.*
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to