Skip to content

Commit 1f4fb2d

Browse files
committed
rename worker probe, add comment
1 parent 5bf3b12 commit 1f4fb2d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

server/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ static class ExecutorScalingQueue<E> extends LinkedTransferQueue<E> {
456456

457457
@Override
458458
public boolean offer(E e) {
459-
if (e == EsThreadPoolExecutor.NOOP_PROBE) { // referential equality
459+
if (e == EsThreadPoolExecutor.WORKER_PROBE) { // referential equality
460460
// this probe ensures a worker is available after force queueing a task via ForceQueuePolicy
461461
return super.offer(e);
462462
}
@@ -521,7 +521,7 @@ static class ForceQueuePolicy extends EsRejectedExecutionHandler {
521521

522522
@Override
523523
public void rejectedExecution(Runnable task, ThreadPoolExecutor executor) {
524-
if (task == EsThreadPoolExecutor.NOOP_PROBE) { // referential equality
524+
if (task == EsThreadPoolExecutor.WORKER_PROBE) { // referential equality
525525
return;
526526
}
527527
if (rejectAfterShutdown) {
@@ -549,7 +549,7 @@ private void put(ThreadPoolExecutor executor, Runnable task) {
549549
if (probeWorkerPool && task == queue.peek()) { // referential equality
550550
// If the task is at the head of the queue, we can assume the queue was previously empty. In this case available workers
551551
// might have timed out in the meanwhile. To prevent the task from starving, we submit a noop probe to the executor.
552-
executor.execute(EsThreadPoolExecutor.NOOP_PROBE);
552+
executor.execute(EsThreadPoolExecutor.WORKER_PROBE);
553553
}
554554
} catch (final InterruptedException e) {
555555
assert false : "a scaling queue never blocks so a put to it can never be interrupted";

server/src/main/java/org/elasticsearch/common/util/concurrent/EsThreadPoolExecutor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ public class EsThreadPoolExecutor extends ThreadPoolExecutor {
2929

3030
private static final Logger logger = LogManager.getLogger(EsThreadPoolExecutor.class);
3131

32-
// probe to
33-
static final Runnable NOOP_PROBE = () -> {};
32+
// noop probe to prevent starvation of work in the work queue due to ForceQueuePolicy
33+
// https://github.com/elastic/elasticsearch/issues/124667
34+
static final Runnable WORKER_PROBE = () -> {};
3435

3536
private final ThreadContext contextHolder;
3637

@@ -81,7 +82,7 @@ public void setMaximumPoolSize(int maximumPoolSize) {
8182

8283
@Override
8384
public void execute(Runnable command) {
84-
final Runnable wrappedRunnable = command != NOOP_PROBE ? wrapRunnable(command) : NOOP_PROBE;
85+
final Runnable wrappedRunnable = command != WORKER_PROBE ? wrapRunnable(command) : WORKER_PROBE;
8586
try {
8687
super.execute(wrappedRunnable);
8788
} catch (Exception e) {

0 commit comments

Comments
 (0)