[ 
https://issues.apache.org/jira/browse/SOLR-18156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18066804#comment-18066804
 ] 

Pierre Salagnac commented on SOLR-18156:
----------------------------------------

The change in this ticket also fixes a bug when using a non-default stats cache 
(this bug was introduced by SOLR-17859  too).

Before this fix for current SOLR-18156, the root cause was  because of the 
overridden {{IndexSearcher}} created in {{{}SolrIndexSearcher.search(...){}}}. 
This anonymous instance specifies the limits, but it does not override methods 
{{termStatistics(...)}} and {{collectionStatistics(...)}} to provide the 
appropriate stats to Lucene. Consequently, were always using local stats only. 
This issues did not reproduce when there is no query limits since we use 
current 'this' instance for searcher.

After the fix, we override the index searcher only to invoke 
{{super.searchLeaf()}} instead of directly {{{}super.search(){}}}. In this 
case, we directly invoke {{termStatistics(...)}} on the top index searcher, 
which returns the correct stats.

I can locally reproduce this bug by:
 # revert this fix
 # in {{{}TestBaseStatsCacheCloud{}}}, add a limits to queries, like 
{{timeAllowed=10000}}
 # run the test with {{ExactStatsCache}} (done by concrete class 
{{{}TestExactStatsCacheCloud{}}}.

More generally, I wonder whether that's a good idea to override the searcher 
instance for a part of query execution. There are there overridden methods (at 
least {{explain()}} and {{rewrite()}} that may be or maybe not taken into 
account. It seems to me it depends a lot on Lucene internals, that may change 
without any public API changes.

> JoinQuery class cast exception on SolrIndexSearcher when using timeAllowed
> --------------------------------------------------------------------------
>
>                 Key: SOLR-18156
>                 URL: https://issues.apache.org/jira/browse/SOLR-18156
>             Project: Solr
>          Issue Type: Bug
>    Affects Versions: 10.0
>            Reporter: Chris M. Hostetter
>            Assignee: Chris M. Hostetter
>            Priority: Major
>             Fix For: main(11.0), 10.1, 10.0.1
>
>         Attachments: SOLR-18156.patch
>
>
> Beginning with Solr 10.0.0, attempting to use any of the {{join}} QParsers in 
> conjunction with QueryLimits results in a ClassCastException.
> This is because {{JoinQuery.createWeight(...)}} expects it will only ever be 
> called with a {{{}SolrIndexSearcher{}}}, but 
> {{SolrIndexSearcher.seach(Query,Collector)}} is overriddent to create an 
> anonymous {{IndexSearcher}} to use when QueryLimits are enabled.
> This was not a problem in Solr 9.x, because back then the logic for creating 
> an anonymous {{IndexSearcher}} was inside the overridden 
> {{SolrIndexSearcher.seach(List<LeafReaderContext>,Weight,Collector)}} (after 
> the {{Weight}} instance had already been created using the original 
> {{{}SolrIndexSearcher{}}})



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to