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 e47aab2
Show file tree
Hide file tree
Showing 2 changed files with 6 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 @@ -282,6 +282,7 @@ protected void search(List<LeafReaderContext> leaves, Weight weight, Collector c
// reader order here.
if (searchContext.shouldUseTimeSeriesDescSortOptimization()) {
for (int i = leaves.size() - 1; i >= 0; i--) {
// If search is already flagged as timed out, do not continue
searchLeaf(leaves.get(i), weight, collector);
}
} else {
Expand All @@ -305,6 +306,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 311 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#L311

Added line #L311 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 e47aab2

Please sign in to comment.