Skip to content

SOLR-16693: timeAllowed: use more efficient TimeLimitingBulkScorer#1450

Merged
dsmiley merged 5 commits intoapache:mainfrom
dsmiley:solr-16693-timeAllowed
Apr 4, 2023
Merged

SOLR-16693: timeAllowed: use more efficient TimeLimitingBulkScorer#1450
dsmiley merged 5 commits intoapache:mainfrom
dsmiley:solr-16693-timeAllowed

Conversation

@dsmiley
Copy link
Contributor

@dsmiley dsmiley commented Mar 11, 2023

Instead of ExitableDirectoryReader

https://issues.apache.org/jira/browse/SOLR-16693

TODO... maybe allow use of ExitableDirectoryReader via sys prop? BTW there are code paths using the reader that wouldn't use the search method yet may have a timeAllowed param. I think I've seen this in an erroneous (bug or accident; haven't root caused yet) scenario at work but could be valid.

Wish we had benchmarks on this. Any way, it's interesting that all tests pass so easily :-)

throws IOException {
final var queryTimeout = SolrQueryTimeoutImpl.getInstance();
if (queryTimeout.isTimeoutEnabled() == false) {
// no timeout. Pass through to subclass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// no timeout. Pass through to subclass
// no timeout. Pass through to super class

Comment on lines 735 to 736
throw new ExitableDirectoryReader.ExitingReaderException(
"Timed out. Not actually via ExitableDirectoryReader");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe an alternative might be to have a class SolrNotActuallyExitableDirectoryReader extends ExitableDirectoryReader.ExitingReaderException approach which would be thrown here and then over time the various places could be switched over to check for SolrNotActuallyExitableDirectoryReader instead or to have the checks phased out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you're not serious about the name SolrNotActuallyExitableDirectoryReader. Two name proposals:

  • TimeAllowedExceededException -- generic. But despite it being generic, the reality is that there are other exceptions that are effectively similar that would still exist, so maybe give up on trying to be generic?
  • TimeAllowedExceededFromScorerException -- more specific as to what makes this timeout what it is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good; I chose the latter; PR updated.
I think it'd be worthwhile for Lucene to have a base class of these exceptions that is public, therefore Lucene apps can catch one general exception no matter which approach is being taken.

@dsmiley
Copy link
Contributor Author

dsmiley commented Mar 16, 2023

BTW I won't merge this any sooner than the Lucene 9.5 PR merges, so that these both can ultimately ship on the same release.

Proposed CHANGES.txt under improvements:

  • SOLR-16693: For query timeAllowed, switch from ExitableDirectoryReader to TimeLimitingBulkScorer

@dsmiley
Copy link
Contributor Author

dsmiley commented Apr 1, 2023

I plan to merge end of Monday or so.

// 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!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should open up a Lucene issue that gives us a search(...., timeout) method, so that this hack isn't necessary in the future. Though as you mention, that would include adding a similar TimeAllowedExceeded Exception to Lucene.

@dsmiley dsmiley merged commit c9d5bcb into apache:main Apr 4, 2023
@dsmiley dsmiley deleted the solr-16693-timeAllowed branch April 4, 2023 04:21
dsmiley added a commit that referenced this pull request Apr 5, 2023
For timeAllowed: use more efficient TimeLimitingBulkScorer instead of ExitableDirectoryReader

Added sys prop escape hatch: solr.useExitableDirectoryReader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants