fix race condition in SearchPhaseControllerTests#consumerTestCase

This commit is contained in:
jimczi 2020-07-28 18:26:52 +02:00
parent e0286e9bd3
commit 4e4ed6ee48
2 changed files with 5 additions and 5 deletions

View File

@ -277,13 +277,15 @@ class QueryPhaseResultConsumer extends ArraySearchPhaseResults<SearchPhaseResult
}
failure.compareAndSet(null, exc);
MergeTask task = runningTask.get();
runningTask.compareAndSet(task, null);
List<MergeTask> toCancel = new ArrayList<>();
if (task != null) {
runningTask.compareAndSet(task, null);
task.cancel();
toCancel.add(task);
}
queue.stream().forEach(MergeTask::cancel);
queue.stream().forEach(toCancel::add);
queue.clear();
mergeResult = null;
toCancel.stream().forEach(MergeTask::cancel);
}
onPartialMergeFailure.accept(exc);
}

View File

@ -487,8 +487,6 @@ public class SearchPhaseControllerTests extends ESTestCase {
}
SearchPhaseController.ReducedQueryPhase reduce = consumer.reduce();
int numCompletedTasks = (int) (fixedExecutor.getCompletedTaskCount() - beforeCompletedTasks);
assertEquals(numCompletedTasks, reduce.numReducePhases-1);
assertEquals(numTotalReducePhases, reduce.numReducePhases);
assertEquals(numTotalReducePhases, reductions.size());
assertAggReduction(request);