From 35a4420df90f40832c3c786ea64d266bd44e80de Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 2 Feb 2023 09:11:54 +0000 Subject: [PATCH 1/2] Fix PrioritizedThrottledTaskRunnerTests These tests try and execute `maxThreads` concurrent tasks to ensure that the rest of the executor's queue has been processed, but due to #93443 (and the executor's zero timeout) this sometimes doesn't work. This commit fixes the problem by making every thread a core thread so that they do not time out. Closes #92910 --- .../util/concurrent/PrioritizedThrottledTaskRunnerTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedThrottledTaskRunnerTests.java b/server/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedThrottledTaskRunnerTests.java index f1955ebcddacb..14e32a23a415c 100644 --- a/server/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedThrottledTaskRunnerTests.java +++ b/server/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedThrottledTaskRunnerTests.java @@ -39,7 +39,7 @@ public class PrioritizedThrottledTaskRunnerTests extends ESTestCase { public void setUp() throws Exception { super.setUp(); maxThreads = between(1, 10); - executor = EsExecutors.newScaling("test", 1, maxThreads, 0, TimeUnit.MILLISECONDS, false, threadFactory, threadContext); + executor = EsExecutors.newScaling("test", maxThreads, maxThreads, 0, TimeUnit.NANOSECONDS, false, threadFactory, threadContext); } @Override From ab75bf1df7cf77a84f2a44c0f037baaa2eac414b Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 2 Feb 2023 09:48:50 +0000 Subject: [PATCH 2/2] Fix testFailsTasksOnRejectionOrShutdown too --- .../util/concurrent/PrioritizedThrottledTaskRunnerTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedThrottledTaskRunnerTests.java b/server/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedThrottledTaskRunnerTests.java index 14e32a23a415c..01ecce705856f 100644 --- a/server/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedThrottledTaskRunnerTests.java +++ b/server/src/test/java/org/elasticsearch/common/util/concurrent/PrioritizedThrottledTaskRunnerTests.java @@ -197,7 +197,7 @@ public void testEnqueueSpawnsNewTasksUpToMax() throws Exception { public void testFailsTasksOnRejectionOrShutdown() throws Exception { final var executor = randomBoolean() - ? EsExecutors.newScaling("test", 1, maxThreads, 0, TimeUnit.MILLISECONDS, true, threadFactory, threadContext) + ? EsExecutors.newScaling("test", maxThreads, maxThreads, 0, TimeUnit.MILLISECONDS, true, threadFactory, threadContext) : EsExecutors.newFixed("test", maxThreads, between(1, 5), threadFactory, threadContext, false); final var taskRunner = new PrioritizedThrottledTaskRunner("test", between(1, maxThreads * 2), executor); final var totalPermits = between(1, maxThreads * 2);