Skip to content

Commit

Permalink
Fix query timeout handling by checking searchContext.isSearchTimedOut()
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Dec 18, 2024
1 parent b5f651f commit 751ad99
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Skip remote-repositories validations for node-joins when RepositoriesService is not in sync with cluster-state ([#16763](https://github.com/opensearch-project/OpenSearch/pull/16763))
- Fix _list/shards API failing when closed indices are present ([#16606](https://github.com/opensearch-project/OpenSearch/pull/16606))
- Fix remote shards balance ([#15335](https://github.com/opensearch-project/OpenSearch/pull/15335))
- Fix query timeout handling by checking searchContext.isSearchTimedOut() ([#16882](https://github.com/opensearch-project/OpenSearch/pull/16882))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,10 @@ protected void search(List<LeafReaderContext> leaves, Weight weight, Collector c
*/
@Override
protected void searchLeaf(LeafReaderContext ctx, Weight weight, Collector collector) throws IOException {
// If search is already flagged as timed out, do not continue
if (searchContext.isSearchTimedOut()) {
return;

Check warning on line 310 in server/src/main/java/org/opensearch/search/internal/ContextIndexSearcher.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/search/internal/ContextIndexSearcher.java#L310

Added line #L310 was not covered by tests
}

// Check if at all we need to call this leaf for collecting results.
if (canMatch(ctx) == false) {
Expand Down

0 comments on commit 751ad99

Please sign in to comment.