Skip to content

Commit a6e4974

Browse files
committed
iter
1 parent 9d8e64e commit a6e4974

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

server/src/main/java/org/elasticsearch/search/DefaultSearchContext.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,11 @@ private static Executor wrapExecutor(Executor executor) {
241241
AtomicInteger segmentLevelTasks = new AtomicInteger(0);
242242
return command -> {
243243
if (segmentLevelTasks.incrementAndGet() > tpe.getMaximumPoolSize()) {
244-
command.run();
244+
try {
245+
command.run();
246+
} finally {
247+
segmentLevelTasks.decrementAndGet();
248+
}
245249
} else {
246250
executor.execute(() -> {
247251
try {

server/src/test/java/org/elasticsearch/search/DefaultSearchContextTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,8 +1056,8 @@ public int size() {
10561056
assertThat(executor.getCompletedTaskCount(), greaterThanOrEqualTo((long) numIters * executorPoolSize));
10571057
// while we parallelize we also limit the number of tasks that each searcher submits
10581058
assertThat(executor.getCompletedTaskCount(), lessThan((long) numIters * numSegmentTasks));
1059-
// *2 is just a wild guess to account for tasks that get executed while we are still submitting
1060-
assertThat(executor.getCompletedTaskCount(), lessThan((long) numIters * executorPoolSize * 2));
1059+
// *3 is just a wild guess to account for tasks that get executed while we are still submitting
1060+
assertThat(executor.getCompletedTaskCount(), lessThan((long) numIters * executorPoolSize * 3));
10611061
}
10621062

10631063
private void doTestSearchConcurrency(ThreadPoolExecutor executor, int numIters, int numSegmentTasks, AtomicInteger completedTasks)

0 commit comments

Comments
 (0)