Search in sources :

Example 1 with UnrecoverableIllegalStateException

use of org.apache.cassandra.exceptions.UnrecoverableIllegalStateException in project cassandra by apache.

the class JVMStabilityInspector method inspectThrowable.

public static void inspectThrowable(Throwable t, Consumer<Throwable> fn) throws OutOfMemoryError {
    boolean isUnstable = false;
    if (t instanceof OutOfMemoryError) {
        if (Boolean.getBoolean("cassandra.printHeapHistogramOnOutOfMemoryError")) {
            // time span.
            synchronized (lock) {
                if (printingHeapHistogram)
                    return;
                printingHeapHistogram = true;
            }
            HeapUtils.logHeapHistogram();
        }
        logger.error("OutOfMemory error letting the JVM handle the error:", t);
        StorageService.instance.removeShutdownHook();
        forceHeapSpaceOomMaybe((OutOfMemoryError) t);
        // the JVM behavior in case of OOM (CASSANDRA-13006).
        throw (OutOfMemoryError) t;
    } else if (t instanceof UnrecoverableIllegalStateException) {
        isUnstable = true;
    }
    if (t instanceof InterruptedException)
        throw new UncheckedInterruptedException((InterruptedException) t);
    if (DatabaseDescriptor.getDiskFailurePolicy() == Config.DiskFailurePolicy.die)
        if (t instanceof FSError || t instanceof CorruptSSTableException)
            isUnstable = true;
    // Check for file handle exhaustion
    if (t instanceof FileNotFoundException || t instanceof FileSystemException || t instanceof SocketException)
        if (t.getMessage() != null && t.getMessage().contains("Too many open files"))
            isUnstable = true;
    if (isUnstable) {
        if (!StorageService.instance.isDaemonSetupCompleted())
            FileUtils.handleStartupFSError(t);
        killer.killCurrentJVM(t);
    }
    try {
        fn.accept(t);
    } catch (Exception | Error e) {
        logger.warn("Unexpected error while handling unexpected error", e);
    }
    if (t.getCause() != null)
        inspectThrowable(t.getCause(), fn);
}
Also used : SocketException(java.net.SocketException) FSError(org.apache.cassandra.io.FSError) FileNotFoundException(java.io.FileNotFoundException) FSError(org.apache.cassandra.io.FSError) UnrecoverableIllegalStateException(org.apache.cassandra.exceptions.UnrecoverableIllegalStateException) CorruptSSTableException(org.apache.cassandra.io.sstable.CorruptSSTableException) UncheckedInterruptedException(org.apache.cassandra.utils.concurrent.UncheckedInterruptedException) SocketException(java.net.SocketException) UnrecoverableIllegalStateException(org.apache.cassandra.exceptions.UnrecoverableIllegalStateException) FileSystemException(java.nio.file.FileSystemException) FileNotFoundException(java.io.FileNotFoundException) UncheckedInterruptedException(org.apache.cassandra.utils.concurrent.UncheckedInterruptedException) CorruptSSTableException(org.apache.cassandra.io.sstable.CorruptSSTableException) FileSystemException(java.nio.file.FileSystemException) UncheckedInterruptedException(org.apache.cassandra.utils.concurrent.UncheckedInterruptedException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 SocketException (java.net.SocketException)1 FileSystemException (java.nio.file.FileSystemException)1 UnrecoverableIllegalStateException (org.apache.cassandra.exceptions.UnrecoverableIllegalStateException)1 FSError (org.apache.cassandra.io.FSError)1 CorruptSSTableException (org.apache.cassandra.io.sstable.CorruptSSTableException)1 UncheckedInterruptedException (org.apache.cassandra.utils.concurrent.UncheckedInterruptedException)1