Skip to content
Permalink
Browse files
jvm-dtest unhandled exceptions failing the test no longer work
patch by David Capwell; reviewed by Benedict Elliott Smith for CASSANDRA-17549
  • Loading branch information
David Capwell committed May 13, 2022
1 parent 7dbea1a commit f451c2b02827fd1db34a14e7603a52ffe4fb188e
Showing 7 changed files with 13 additions and 8 deletions.
@@ -61,7 +61,7 @@ public static void handle(Throwable t)
{
Thread thread = Thread.currentThread();
Thread.UncaughtExceptionHandler handler = thread.getUncaughtExceptionHandler();
if (handler == null || handler.equals(thread.getThreadGroup()))
if (handler == null)
handler = JVMStabilityInspector::uncaughtException;
handler.uncaughtException(thread, t);
}
@@ -366,7 +366,7 @@ Future<List<SyncStat>> executeTasks(List<SyncTask> tasks)
}
catch (NoSuchRepairSessionException e)
{
throw new NoSuchRepairSessionExceptionWrapper(e);
return ImmediateFuture.failure(new NoSuchRepairSessionExceptionWrapper(e));
}
}

@@ -51,6 +51,7 @@
import org.apache.cassandra.auth.AuthCache;
import org.apache.cassandra.batchlog.Batch;
import org.apache.cassandra.batchlog.BatchlogManager;
import org.apache.cassandra.concurrent.ExecutorFactory;
import org.apache.cassandra.concurrent.ExecutorLocals;
import org.apache.cassandra.concurrent.ExecutorPlus;
import org.apache.cassandra.concurrent.ScheduledExecutors;
@@ -547,6 +548,9 @@ public void startup(ICluster cluster)
sync(() -> {
try
{
// org.apache.cassandra.distributed.impl.AbstractCluster.startup sets the exception handler for the thread
// so extract it to populate ExecutorFactory.Global
ExecutorFactory.Global.unsafeSet(new ExecutorFactory.Default(Thread.currentThread().getContextClassLoader(), null, Thread.getDefaultUncaughtExceptionHandler()));
if (config.has(GOSSIP))
{
// TODO: hacky
@@ -734,9 +738,6 @@ public Future<Void> shutdown()
@Override
public Future<Void> shutdown(boolean graceful)
{
if (!graceful && config.has(NETWORK))
MessagingService.instance().shutdown(1L, MINUTES, false, true);

Future<?> future = async((ExecutorService executor) -> {
Throwable error = null;

@@ -45,7 +45,7 @@ public void testFailingTruncation() throws IOException
.withInstanceInitializer(BBFailHelper::install)
.start()))
{

cluster.setUncaughtExceptionsFilter(t -> "truncateBlocking".equals(t.getMessage()));
System.setProperty(BB_FAIL_HELPER_PROP, "true");
cluster.schemaChange("create table " + KEYSPACE + ".tbl (id int primary key, t int)");
try
@@ -78,7 +78,7 @@ static void install(ClassLoader cl, int nodeNumber)
public static void truncateBlocking()
{
if (Boolean.getBoolean(BB_FAIL_HELPER_PROP))
throw new RuntimeException();
throw new RuntimeException("truncateBlocking");
}
}
}
@@ -112,7 +112,7 @@ public void nodeDownDuringMove() throws Throwable
}).accept(failAddress);
}

cluster.get(fail).shutdown(false).get();
ClusterUtils.stopAbrupt(cluster, cluster.get(fail));
cluster.get(late).startup();
cluster.get(late).acceptsOnInstance((InetSocketAddress address) -> {
EndpointState ep;
@@ -48,6 +48,7 @@
import org.apache.cassandra.io.util.FileDataInput;
import org.apache.cassandra.service.CassandraDaemon;
import org.apache.cassandra.service.StorageService;
import org.apache.cassandra.utils.Throwables;

import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
import static org.apache.cassandra.distributed.api.Feature.NATIVE_PROTOCOL;
@@ -72,6 +73,7 @@ private static void test(DiskFailurePolicy policy, boolean expectNativeTransport
String table = policy.name();
try (final Cluster cluster = init(getCluster(policy).start()))
{
cluster.setUncaughtExceptionsFilter(t -> Throwables.anyCauseMatches(t, t2 -> t2.getClass().getCanonicalName().equals(CorruptSSTableException.class.getCanonicalName())));
IInvokableInstance node = cluster.get(1);
boolean[] setup = node.callOnInstance(() -> {
CassandraDaemon instanceForTesting = CassandraDaemon.getInstanceForTesting();
@@ -69,6 +69,7 @@ public void testHintsServiceMetrics() throws Exception
.withInstanceInitializer(FailHints::install)
.start())
{
cluster.setUncaughtExceptionsFilter(t -> "Injected failure".equals(t.getMessage()));
// setup a message filter to drop some of the hint request messages from node1
AtomicInteger hintsNode2 = new AtomicInteger();
AtomicInteger hintsNode3 = new AtomicInteger();
@@ -152,6 +153,7 @@ private static void waitUntilAsserted(ThrowingRunnable assertion)
await().atMost(5, MINUTES)
.pollDelay(0, SECONDS)
.pollInterval(1, SECONDS)
.dontCatchUncaughtExceptions()
.untilAsserted(assertion);
}

0 comments on commit f451c2b

Please sign in to comment.