Skip to content

Commit 5c72f24

Browse files
Bound Linearizability Check in CoordinatorTests (#48751)
Same as #44444 but for the coordinator tests. Closes #48752
1 parent be6697f commit 5c72f24

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/framework/src/main/java/org/elasticsearch/cluster/coordination/AbstractCoordinatorTestCase.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import org.elasticsearch.test.ESTestCase;
7070
import org.elasticsearch.test.disruption.DisruptableMockTransport;
7171
import org.elasticsearch.test.disruption.DisruptableMockTransport.ConnectionStatus;
72+
import org.elasticsearch.threadpool.Scheduler;
7273
import org.elasticsearch.threadpool.ThreadPool;
7374
import org.elasticsearch.transport.TransportInterceptor;
7475
import org.elasticsearch.transport.TransportService;
@@ -90,6 +91,9 @@
9091
import java.util.Optional;
9192
import java.util.Set;
9293
import java.util.concurrent.Callable;
94+
import java.util.concurrent.ScheduledThreadPoolExecutor;
95+
import java.util.concurrent.TimeUnit;
96+
import java.util.concurrent.atomic.AtomicBoolean;
9397
import java.util.concurrent.atomic.AtomicInteger;
9498
import java.util.function.BiConsumer;
9599
import java.util.function.Consumer;
@@ -561,7 +565,21 @@ void stabilise(long stabilisationDurationMillis) {
561565
leader.improveConfiguration(lastAcceptedState), sameInstance(lastAcceptedState));
562566

563567
logger.info("checking linearizability of history with size {}: {}", history.size(), history);
564-
assertTrue("history not linearizable: " + history, linearizabilityChecker.isLinearizable(spec, history, i -> null));
568+
final AtomicBoolean abort = new AtomicBoolean();
569+
// Large histories can be problematic and have the linearizability checker run OOM
570+
// Bound the time how long the checker can run on such histories (Values empirically determined)
571+
final ScheduledThreadPoolExecutor scheduler = Scheduler.initScheduler(Settings.EMPTY);
572+
try {
573+
if (history.size() > 300) {
574+
scheduler.schedule(() -> abort.set(true), 10, TimeUnit.SECONDS);
575+
}
576+
final boolean linearizable = linearizabilityChecker.isLinearizable(spec, history, i -> null, abort::get);
577+
if (abort.get() == false) {
578+
assertTrue("history not linearizable: " + history, linearizable);
579+
}
580+
} finally {
581+
ThreadPool.terminate(scheduler, 1, TimeUnit.SECONDS);
582+
}
565583
logger.info("linearizability check completed");
566584
}
567585

0 commit comments

Comments
 (0)