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

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-6831
   
   ## What happens today
   
   **Pivot faceting keeps building pivot values after the request's query 
limits are exceeded.**
   
   Other components check `timeAllowed`, `cpuAllowed` and `memAllowed` between 
units of work, for example 
[QueryComponent](https://github.com/nick-boss-tech/solr/blob/96b33ba5f6f834038e570d0b93f8684dc887fbe8/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java)
 and 
[FacetComponent](https://github.com/nick-boss-tech/solr/blob/96b33ba5f6f834038e570d0b93f8684dc887fbe8/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java).
 Pivot faceting did not. The ticket reports that after `timeAllowed` trips, 
pivot building keeps running lookups that fail, for a long time. At the 
merge-base commit `97d973814336`, the value loop in 
[`doPivots`](https://github.com/nick-boss-tech/solr/blob/97d973814336101e12475558d7419321c743de79/solr/core/src/java/org/apache/solr/handler/component/PivotFacetProcessor.java#L328-L345)
 runs a subset search for every value at every level.
   
   ## What this change does
   
   **The pivot loop checks the query limits before each value and stops at the 
first limit that has tripped.**
   
   
[`doPivots`](https://github.com/nick-boss-tech/solr/blob/96b33ba5f6f834038e570d0b93f8684dc887fbe8/solr/core/src/java/org/apache/solr/handler/component/PivotFacetProcessor.java#L328-L333)
 reads the request's limits once and checks them before each value. When a 
limit has tripped, the loop stops and returns the values built so far. The 
response is marked partial, with the detail "Faceting pivots". The check runs 
at every level, because `doPivots` calls itself for sub-pivots.
   
   Behavior change, stated openly: the check covers every limit the shared code 
knows, so `memAllowed` is included, not only `timeAllowed` and `cpuAllowed`. 
With `partialResults=false`, the request fails with the limit error, as it does 
in other components.
   
   ## Proof
   
   **`TestQueryLimits.testPivotFacetTruncatesWhenLimitsTrip` fails without this 
change and passes with it.**
   
   Base production code with the new test file: `TestQueryLimits` runs 4 tests 
with 1 failure, in `testPivotFacetTruncatesWhenLimitsTrip`. With this change at 
head `96b33ba5f6f834038e570d0b93f8684dc887fbe8`: `TestQueryLimits` 4 of 4 pass. 
Verified at this head. The new test is at 
[TestQueryLimits.java#L135-L188](https://github.com/nick-boss-tech/solr/blob/96b33ba5f6f834038e570d0b93f8684dc887fbe8/solr/core/src/test/org/apache/solr/search/TestQueryLimits.java#L135-L188).
   
   `testPivotFacetRespectsLimits` passes with and without this change. It 
checks the partial marker and the trip detail only. The limit trip in both new 
tests is injected through a test hook (`CallerSpecificQueryLimit`), not a real 
`timeAllowed` or `cpuAllowed` run.
   
   ## Limits
   
   **The check runs between values. A limit that trips inside one value's 
search is not stopped sooner.**
   
   - A limit that trips inside one value's subset search ends that search as 
before. This change does not stop it earlier.
   - The ticket points at the searcher's exception handling. This change does 
not touch that code. A follow-up in the searcher can be opened on request.
   - No test measures how many lookups are saved. The tests check the response 
shape at the trip point.
   
   Changelog: 
[`changelog/unreleased/SOLR-6831-pivot-facet-limits.yml`](https://github.com/nick-boss-tech/solr/blob/96b33ba5f6f834038e570d0b93f8684dc887fbe8/changelog/unreleased/SOLR-6831-pivot-facet-limits.yml)
   
   ### AI assistance
   
   AI agents assisted with research, implementation, review, and drafting. 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