Skip to content

Commit cbb62c2

Browse files
authored
Fix SearchProgressActionListenerIT (#120888)
This fixes SearchProgressActionListenerIT by notifying the search progress listener before search operation terminates.
1 parent d60e6fa commit cbb62c2

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

muted-tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,6 @@ tests:
213213
issue: https://github.com/elastic/elasticsearch/issues/120482
214214
- class: org.elasticsearch.xpack.sql.expression.function.scalar.datetime.DateTimeToCharProcessorTests
215215
issue: https://github.com/elastic/elasticsearch/issues/120575
216-
- class: org.elasticsearch.action.search.SearchProgressActionListenerIT
217-
method: testSearchProgressWithHitsAndAggs
218-
issue: https://github.com/elastic/elasticsearch/issues/120583
219216
- class: org.elasticsearch.index.reindex.BulkByScrollUsesAllScrollDocumentsAfterConflictsIntegTests
220217
method: testReindex
221218
issue: https://github.com/elastic/elasticsearch/issues/120605
@@ -232,9 +229,6 @@ tests:
232229
issue: https://github.com/elastic/elasticsearch/issues/120767
233230
- class: org.elasticsearch.search.fieldcaps.FieldCapabilitiesIT
234231
issue: https://github.com/elastic/elasticsearch/issues/120772
235-
- class: org.elasticsearch.action.search.SearchProgressActionListenerIT
236-
method: testSearchProgressWithHits
237-
issue: https://github.com/elastic/elasticsearch/issues/120671
238232
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
239233
method: test {p0=ml/3rd_party_deployment/Test start deployment fails while model download in progress}
240234
issue: https://github.com/elastic/elasticsearch/issues/120810

server/src/main/java/org/elasticsearch/action/search/FetchSearchPhase.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,21 @@ private void innerRunFetch(ScoreDoc[] scoreDocs, int numShards, SearchPhaseContr
158158
);
159159
for (int i = 0; i < docIdsToLoad.length; i++) {
160160
List<Integer> entry = docIdsToLoad[i];
161+
SearchPhaseResult shardPhaseResult = searchPhaseShardResults.get(i);
161162
if (entry == null) { // no results for this shard ID
162163
// if we got some hits from this shard we have to release the context
163164
// we do this below after sending out the fetch requests relevant to the search to give priority to those requests
164165
// that contribute to the final search response
165166
// in any case we count down this result since we don't talk to this shard anymore
167+
if (shardPhaseResult != null) {
168+
// notifying the listener here as otherwise the search operation might finish before we
169+
// get a chance to notify the progress listener for some fetch results
170+
progressListener.notifyFetchResult(i);
171+
}
166172
counter.countDown();
167173
} else {
168174
executeFetch(
169-
searchPhaseShardResults.get(i),
175+
shardPhaseResult,
170176
counter,
171177
entry,
172178
rankDocsPerShard == null || rankDocsPerShard.get(i).isEmpty() ? null : new RankDocShardInfo(rankDocsPerShard.get(i)),
@@ -179,7 +185,6 @@ private void innerRunFetch(ScoreDoc[] scoreDocs, int numShards, SearchPhaseContr
179185
SearchPhaseResult shardPhaseResult = searchPhaseShardResults.get(i);
180186
if (shardPhaseResult != null) {
181187
releaseIrrelevantSearchContext(shardPhaseResult, context);
182-
progressListener.notifyFetchResult(i);
183188
}
184189
}
185190
}

0 commit comments

Comments
 (0)