|
69 | 69 | import org.elasticsearch.test.ESTestCase;
|
70 | 70 | import org.elasticsearch.test.disruption.DisruptableMockTransport;
|
71 | 71 | import org.elasticsearch.test.disruption.DisruptableMockTransport.ConnectionStatus;
|
| 72 | +import org.elasticsearch.threadpool.Scheduler; |
72 | 73 | import org.elasticsearch.threadpool.ThreadPool;
|
73 | 74 | import org.elasticsearch.transport.TransportInterceptor;
|
74 | 75 | import org.elasticsearch.transport.TransportService;
|
|
90 | 91 | import java.util.Optional;
|
91 | 92 | import java.util.Set;
|
92 | 93 | import java.util.concurrent.Callable;
|
| 94 | +import java.util.concurrent.ScheduledThreadPoolExecutor; |
| 95 | +import java.util.concurrent.TimeUnit; |
| 96 | +import java.util.concurrent.atomic.AtomicBoolean; |
93 | 97 | import java.util.concurrent.atomic.AtomicInteger;
|
94 | 98 | import java.util.function.BiConsumer;
|
95 | 99 | import java.util.function.Consumer;
|
@@ -561,7 +565,21 @@ void stabilise(long stabilisationDurationMillis) {
|
561 | 565 | leader.improveConfiguration(lastAcceptedState), sameInstance(lastAcceptedState));
|
562 | 566 |
|
563 | 567 | 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 | + } |
565 | 583 | logger.info("linearizability check completed");
|
566 | 584 | }
|
567 | 585 |
|
|
0 commit comments