Skip to content

Commit 075be86

Browse files
committed
Make sure blocked task is dequeued before refreshing cluster info
1 parent c28de52 commit 075be86

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/WriteLoadConstraintDeciderIT.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,20 @@ public void testMaxQueueLatencyMetricIsPublished() {
285285
final String dataNodeToDelay = randomFrom(dataNodes);
286286
final ThreadPool threadPoolToDelay = internalCluster().getInstance(ThreadPool.class, dataNodeToDelay);
287287

288-
// Fill the write thread pool and block a task for some time
288+
// Fill the write thread pool
289289
final int writeThreadPoolSize = threadPoolToDelay.info(ThreadPool.Names.WRITE).getMax();
290290
final var latch = new CountDownLatch(1);
291291
final var writeThreadPool = threadPoolToDelay.executor(ThreadPool.Names.WRITE);
292-
range(0, writeThreadPoolSize + 1).forEach(i -> writeThreadPool.execute(() -> safeAwait(latch)));
292+
range(0, writeThreadPoolSize).forEach(i -> writeThreadPool.execute(() -> safeAwait(latch)));
293+
// Submit a task that will be blocked
294+
final var blockedTask = writeThreadPool.submit(() -> {
295+
// Doesnt need to do anything
296+
});
293297
final long delayMillis = randomIntBetween(100, 200);
294298
safeSleep(delayMillis);
295299
// Unblock the pool
296300
latch.countDown();
301+
safeGet(blockedTask);
297302

298303
refreshClusterInfo(masterName);
299304
mostRecentQueueLatencyMetrics = getMostRecentQueueLatencyMetrics(dataNodes);

0 commit comments

Comments
 (0)