Skip to content

Commit 3f6af9d

Browse files
authored
Fix flaky ThreadPoolMergeSchedulerStressTestIT (#139819) (#140343)
* Increase wait time for flaky test Increasing maxWaitTime for merges to start and complete to 10 minutes. The previous time out of 1 minute leave room for scheduling variability to tip the test over the wait threshold and fail the test. If test stills fails on 10 minute timeout we can be quite sure that it hangs. * Bind node processors setting in test Some CI environments only have 4 cores and will fail this test if rnd gods are grumpy and generate a 5 or higher. NODE_PROCESSORS_SETTING is limited to the number of available processors.
1 parent 56d604c commit 3f6af9d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

server/src/internalClusterTest/java/org/elasticsearch/index/engine/ThreadPoolMergeSchedulerStressTestIT.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ protected Settings nodeSettings() {
6262
.put(ThreadPoolMergeScheduler.USE_THREAD_POOL_MERGE_SCHEDULER_SETTING.getKey(), true)
6363
// when there are more threads than scheduler(s)' concurrency capacity, excess merges will be backlogged
6464
// alternatively, when scheduler(s)' concurrency capacity exceeds the executor's thread count, excess merges will be enqueued
65-
.put(EsExecutors.NODE_PROCESSORS_SETTING.getKey(), MERGE_SCHEDULER_MAX_CONCURRENCY + randomFrom(-2, -1, 0, 1, 2))
65+
.put(
66+
EsExecutors.NODE_PROCESSORS_SETTING.getKey(),
67+
Math.min(MERGE_SCHEDULER_MAX_CONCURRENCY + randomFrom(-2, -1, 0, 1, 2), Runtime.getRuntime().availableProcessors())
68+
)
6669
.build();
6770
}
6871

@@ -87,6 +90,7 @@ class TestInternalEngine extends org.elasticsearch.index.engine.InternalEngine {
8790
super(engineConfig);
8891
}
8992

93+
@Override
9094
protected ElasticsearchMergeScheduler createMergeScheduler(
9195
ShardId shardId,
9296
IndexSettings indexSettings,
@@ -255,7 +259,7 @@ public void testMergingFallsBehindAndThenCatchesUp() throws Exception {
255259
assertBusy(() -> {
256260
// wait for merges to enqueue or backlog
257261
assertThat(testEnginePlugin.enqueuedMergesSet.size(), greaterThanOrEqualTo(testEnginePlugin.waitMergesEnqueuedCount));
258-
}, 1, TimeUnit.MINUTES);
262+
}, 10, TimeUnit.MINUTES);
259263
// finish up indexing
260264
indexingDone.set(true);
261265
for (Thread indexingThread : indexingThreads) {
@@ -271,7 +275,7 @@ public void testMergingFallsBehindAndThenCatchesUp() throws Exception {
271275
assertThat(testEnginePlugin.runningMergesSet.size(), is(0));
272276
assertThat(testEnginePlugin.enqueuedMergesSet.size(), is(0));
273277
testEnginePlugin.mergeExecutorServiceReference.get().allDone();
274-
}, 1, TimeUnit.MINUTES);
278+
}, 10, TimeUnit.MINUTES);
275279
// indices stats says that no merge is currently running (meaning merging did catch up)
276280
IndicesStatsResponse indicesStatsResponse = client().admin().indices().prepareStats("index").setMerge(true).get();
277281
long currentMergeCount = indicesStatsResponse.getIndices().get("index").getPrimaries().merge.getCurrent();

0 commit comments

Comments
 (0)