Fix race condition in SearchPhaseControllerTests#testPartialMergeFailure (#60488)

This change ensures that we call the listener for partial merge failure **before**
calling the completion listener in order to avoid race condition in tests.

Closes #60446
This commit is contained in:
Jim Ferenczi 2020-07-31 15:38:51 +02:00 committed by jimczi
parent 4b12e69e8e
commit 8db896d290
1 changed files with 1 additions and 1 deletions

View File

@ -278,6 +278,7 @@ class QueryPhaseResultConsumer extends ArraySearchPhaseResults<SearchPhaseResult
failure.compareAndSet(null, exc);
MergeTask task = runningTask.get();
runningTask.compareAndSet(task, null);
onPartialMergeFailure.accept(exc);
List<MergeTask> toCancel = new ArrayList<>();
if (task != null) {
toCancel.add(task);
@ -287,7 +288,6 @@ class QueryPhaseResultConsumer extends ArraySearchPhaseResults<SearchPhaseResult
mergeResult = null;
toCancel.stream().forEach(MergeTask::cancel);
}
onPartialMergeFailure.accept(exc);
}
private void onAfterMerge(MergeTask task, MergeResult newResult) {