cpoerschke commented on code in PR #1450: URL: https://github.com/apache/solr/pull/1450#discussion_r1138283647
########## solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java: ########## @@ -713,6 +713,33 @@ public QueryResult search(QueryResult qr, QueryCommand cmd) throws IOException { return qr; } + @Override + protected void search(List<LeafReaderContext> leaves, Weight weight, Collector collector) + throws IOException { + final var queryTimeout = SolrQueryTimeoutImpl.getInstance(); + if (queryTimeout.isTimeoutEnabled() == false) { + // no timeout. Pass through to subclass + super.search(leaves, weight, collector); + } else { + // Timeout enabled! This impl is maybe a hack. Use Lucene's IndexSearcher timeout. + // But only some queries have it so don't use on "this" (SolrIndexSearcher), not to mention + // that timedOut() might race with concurrent queries (dubious design). + // So we need to make a new IndexSearcher instead of using "this". + new IndexSearcher(reader) { // cheap, actually! + void searchWithTimeout() throws IOException { + setTimeout(queryTimeout.makeLocalImpl()); + super.search(leaves, weight, collector); // FYI protected access + if (timedOut()) { + // We might not even be using ExitableDirectoryReader yet various places in Solr check + // for this exception. Sometimes others but this seems most suitable. + throw new ExitableDirectoryReader.ExitingReaderException( + "Timed out. Not actually via ExitableDirectoryReader"); Review Comment: > I assume you're not serious about the name SolrNotActuallyExitableDirectoryReader. Two name proposals: ... Yeah, that was not meant to be a serious name suggestion but only a way to convey the `class ... extends ExitableDirectoryReader.ExitingReaderException` idea. `TimeAllowedExceededException` vs. `TimeAllowedExceededFromScorerException` -- the latter to me seems closer to the current `ExitableDirectoryReader.ExitingReaderException` which is also pretty specific. -- 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: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org