Skip to content

Commit e47aab2

Browse files
committed
Fix query timeout handling by checking searchContext.isSearchTimedOut()
Signed-off-by: Andriy Redko <[email protected]>
1 parent b5f651f commit e47aab2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
7474
- 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))
7575
- Fix _list/shards API failing when closed indices are present ([#16606](https://github.com/opensearch-project/OpenSearch/pull/16606))
7676
- Fix remote shards balance ([#15335](https://github.com/opensearch-project/OpenSearch/pull/15335))
77+
- Fix query timeout handling by checking searchContext.isSearchTimedOut() ([#16882](https://github.com/opensearch-project/OpenSearch/pull/16882))
7778

7879
### Security
7980

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ protected void search(List<LeafReaderContext> leaves, Weight weight, Collector c
282282
// reader order here.
283283
if (searchContext.shouldUseTimeSeriesDescSortOptimization()) {
284284
for (int i = leaves.size() - 1; i >= 0; i--) {
285+
// If search is already flagged as timed out, do not continue
285286
searchLeaf(leaves.get(i), weight, collector);
286287
}
287288
} else {
@@ -305,6 +306,10 @@ protected void search(List<LeafReaderContext> leaves, Weight weight, Collector c
305306
*/
306307
@Override
307308
protected void searchLeaf(LeafReaderContext ctx, Weight weight, Collector collector) throws IOException {
309+
// If search is already flagged as timed out, do not continue
310+
if (searchContext.isSearchTimedOut()) {
311+
return;
312+
}
308313

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

0 commit comments

Comments
 (0)