Skip to content

Commit a255537

Browse files
Fix ThreadPoolMergeSchedulerStressTestIT testMergingFallsBehindAndThenCatchesUp (#125956)
We don't know how many semaphore merge permits we need to release, or how many are already released. Fixes #125744
1 parent 5727a1f commit a255537

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,6 @@ public static class TestEnginePlugin extends Plugin implements EnginePlugin {
7979
final Semaphore runMergeSemaphore = new Semaphore(initialRunMergesCount);
8080
final int waitMergesEnqueuedCount = randomIntBetween(50, 100);
8181

82-
void allowAllMerging() {
83-
// even when indexing is done, queued and backlogged merges can themselves trigger further merging
84-
// don't let this test be bothered by that, and simply let all merging run unhindered
85-
runMergeSemaphore.release(Integer.MAX_VALUE - initialRunMergesCount);
86-
}
87-
8882
class TestInternalEngine extends org.elasticsearch.index.engine.InternalEngine {
8983

9084
TestInternalEngine(EngineConfig engineConfig) {
@@ -265,10 +259,13 @@ public void testMergingFallsBehindAndThenCatchesUp() throws Exception {
265259
for (Thread indexingThread : indexingThreads) {
266260
indexingThread.join();
267261
}
268-
// unblock merge threads
269-
testEnginePlugin.allowAllMerging();
262+
// even when indexing is done, queued and backlogged merges can themselves trigger further merging
263+
// don't let this test be bothered by that, and simply unblock all merges
264+
// 100k is a fudge value, but there's no easy way to find a smartest one here
265+
testEnginePlugin.runMergeSemaphore.release(100_000);
270266
// await all merging to catch up
271267
assertBusy(() -> {
268+
assert testEnginePlugin.runMergeSemaphore.availablePermits() > 0 : "some merges are blocked, test is broken";
272269
assertThat(testEnginePlugin.runningMergesSet.size(), is(0));
273270
assertThat(testEnginePlugin.enqueuedMergesSet.size(), is(0));
274271
testEnginePlugin.mergeExecutorServiceReference.get().allDone();

0 commit comments

Comments
 (0)