Skip to content

Commit

Permalink
fix race condition in SearchPhaseControllerTests#consumerTestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczi committed Jul 28, 2020
1 parent e0286e9 commit 4e4ed6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,15 @@ private void onMergeFailure(Exception exc) {
}
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,6 @@ private void consumerTestCase(int numEmptyResponses) throws Exception {
}

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);
Expand Down

0 comments on commit 4e4ed6e

Please sign in to comment.