{"record":{"id":"7786f618ea6852d7","repo":"apache/cassandra","slug":"the-jvm-is-not-configured-to-stop-on-outofmemoryer","errorCode":null,"errorMessage":"The JVM is not configured to stop on OutOfMemoryError which can cause data corruption. Use one of the following JVM options to configure the behavior on OutOfMemoryError:  -XX:+ExitOnOutOfMemoryError, -XX:+CrashOnOutOfMemoryError, or -XX:OnOutOfMemoryError=\"<cmd args>;<cmd args>\"","messagePattern":"The JVM is not configured to stop on OutOfMemoryError which can cause data corruption\\. Use one of the following JVM options to configure the behavior on OutOfMemoryError:  -XX:\\+ExitOnOutOfMemoryError, -XX:\\+CrashOnOutOfMemoryError, or -XX:OnOutOfMemoryError=\"<cmd args>;<cmd args>\"","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/service/StartupChecks.java","lineNumber":620,"sourceCode":"            if (!(javaVmName.contains(\"HotSpot\") || javaVmName.contains(\"OpenJDK\")))\n            {\n                logger.warn(\"Non-Oracle JVM detected.  Some features, such as immediate unmap of compacted SSTables, may not work as intended\");\n            }\n            else\n            {\n                checkOutOfMemoryHandling();\n            }\n        }\n\n        /**\n         * Checks that the JVM is configured to handle OutOfMemoryError\n         */\n        private void checkOutOfMemoryHandling()\n        {\n            if (JavaUtils.supportExitOnOutOfMemory(JAVA_VERSION.getString()))\n            {\n                if (!jvmOptionsContainsOneOf(\"-XX:OnOutOfMemoryError=\", \"-XX:+ExitOnOutOfMemoryError\", \"-XX:+CrashOnOutOfMemoryError\"))\n                    logger.warn(\"The JVM is not configured to stop on OutOfMemoryError which can cause data corruption.\"\n                                + \" Use one of the following JVM options to configure the behavior on OutOfMemoryError: \"\n                                + \" -XX:+ExitOnOutOfMemoryError, -XX:+CrashOnOutOfMemoryError, or -XX:OnOutOfMemoryError=\\\"<cmd args>;<cmd args>\\\"\");\n            }\n            else\n            {\n                if (!jvmOptionsContainsOneOf(\"-XX:OnOutOfMemoryError=\"))\n                    logger.warn(\"The JVM is not configured to stop on OutOfMemoryError which can cause data corruption.\"\n                            + \" Either upgrade your JRE to a version greater or equal to 8u92 and use -XX:+ExitOnOutOfMemoryError/-XX:+CrashOnOutOfMemoryError\"\n                            + \" or use -XX:OnOutOfMemoryError=\\\"<cmd args>;<cmd args>\\\" on your current JRE.\");\n            }\n        }\n\n        /**\n         * Checks if one of the specified options is being used.\n         * @param optionNames The name of the options to check\n         * @return {@code true} if one of the specified options is being used, {@code false} otherwise.\n         */\n        private boolean jvmOptionsContainsOneOf(String... optionNames)","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StartupChecks.java#L602-L638","documentation":"On a HotSpot/OpenJDK JVM, checkOutOfMemoryHandling verifies that at least one -XX:OnOutOfMemoryError=, -XX:+ExitOnOutOfMemoryError, or -XX:+CrashOnOutOfMemoryError option is present when the JVM supports them (Java >= 8u92 per JavaUtils.supportExitOnOutOfMemory). Without one, a node that hits OutOfMemoryError keeps running in a corrupt/undefined state, which can cause data corruption. This is a logged warning during startup.","triggerScenarios":"JVM version >= 8u92, JVM args (JVM_OPTS / jvm.options / cassandra-env.sh) contain none of the three -XX OOM-handling options when StartupChecks run.","commonSituations":"Hand-edited jvm11/jvm17 options files that dropped the flag, custom launchers bypassing cassandra-env.sh, docker images overriding JVM_OPTS, upgrades where the OOM flag was lost in a merge.","solutions":["Add -XX:+ExitOnOutOfMemoryError to jvm.options (or JVM_OPTS) and restart.","Alternatively add -XX:+CrashOnOutOfMemoryError if you want a core dump for diagnosis.","Use -XX:OnOutOfMemoryError=\"<cmd args>\" to run a custom handler script (e.g. kill the process, alert).","Verify with `ps -ef | grep cassandra` or jcmd VM.flags that the option took effect."],"exampleFix":"// before (jvm.options)\n# no OOM handling option\n// after (jvm.options)\n-XX:+ExitOnOutOfMemoryError","handlingStrategy":"validation","validationCode":"// Check effective JVM flags before startup\nProcess p = Runtime.getRuntime().exec(new String[]{\"sh\",\"-c\",\"jcmd 0 VM.flags | grep -E 'ExitOnOutOfMemoryError|CrashOnOutOfMemoryError|OnOutOfMemoryError'\")});\nif (p.waitFor() == 0 && new String(p.getInputStream().readAllBytes()).isBlank()) {\n    System.out.println(\"Add -XX:+ExitOnOutOfMemoryError to jvm.options\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always ship -XX:+ExitOnOutOfMemoryError in jvm.options (or OnOutOfMemoryError with a kill script).","Diff jvm.options against the upstream template after every Cassandra upgrade.","Verify flags with `jcmd <pid> VM.flags` post-deploy.","Pair the flag with systemd automatic restart so OOM-killed nodes rejoin."],"tags":["jvm","outofmemory","startup-check","configuration"],"backgroundTag":"missing-config-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}