From 3e0b94565acc64e903d73af3a14b23c875abc5b3 Mon Sep 17 00:00:00 2001 From: Josh McKenzie Date: Tue, 2 Aug 2022 16:02:03 -0400 Subject: [PATCH] Add support to generate a One-Shot heap dump on unhandled exceptions Patch by Caleb Rackliffe; reviewed by Josh McKenzie, David Capwell, and Jon Meredith for CASSANDRA-17795 Co-authored-by: Caleb Rackliffe Co-authored-by: Josh McKenzie --- CHANGES.txt | 1 + build.xml | 1 + conf/cassandra.yaml | 10 +++ ide/idea/workspace.xml | 6 +- .../org/apache/cassandra/config/Config.java | 3 + .../cassandra/config/DatabaseDescriptor.java | 79 ++++++++++++++++++ .../cassandra/service/StorageProxy.java | 12 +++ .../cassandra/service/StorageProxyMBean.java | 3 + .../org/apache/cassandra/utils/HeapUtils.java | 82 ++++++++++++++++++- .../utils/JVMStabilityInspector.java | 3 + test/conf/cassandra.yaml | 3 + .../apache/cassandra/utils/HeapUtilsTest.java | 63 ++++++++++++++ .../cassandra/tools/BulkLoaderTest.java | 26 +++--- 13 files changed, 277 insertions(+), 15 deletions(-) create mode 100644 test/long/org/apache/cassandra/utils/HeapUtilsTest.java diff --git a/CHANGES.txt b/CHANGES.txt index 3aaaf8b38e..dd09b25c56 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.2 + * Add support to generate a One-Shot heap dump on unhandled exceptions (CASSANDRA-17795) * Rate-limit new client connection auth setup to avoid overwhelming bcrypt (CASSANDRA-17812) * DataOutputBuffer#scratchBuffer can use off-heap or on-heap memory as a means to control memory allocations (CASSANDRA-16471) * Add ability to read the TTLs and write times of the elements of a collection and/or UDT (CASSANDRA-8877) diff --git a/build.xml b/build.xml index ca346c9f28..82a805d5d8 100644 --- a/build.xml +++ b/build.xml @@ -1500,6 +1500,7 @@ more aggressively rather than waiting. See CASSANDRA-14922 for more details. --> + diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml index 98d70a035f..21e3f78c10 100644 --- a/conf/cassandra.yaml +++ b/conf/cassandra.yaml @@ -107,6 +107,16 @@ auto_hints_cleanup_enabled: false # parameters: # - +# Directory where Cassandra should store results of a One-Shot troubleshooting heapdump for uncaught exceptions. +# Note: this value can be overridden by the -XX:HeapDumpPath JVM env param with a relative local path for testing if +# so desired. +# If not set, the default directory is $CASSANDRA_HOME/heapdump +# heap_dump_path: /var/lib/cassandra/heapdump + +# Enable / disable automatic dump of heap on first uncaught exception +# If not set, the default value is false +# dump_heap_on_uncaught_exception: true + # Enable / disable persistent hint windows. # # If set to false, a hint will be stored only in case a respective node diff --git a/ide/idea/workspace.xml b/ide/idea/workspace.xml index e35ba90ac7..321edd8024 100644 --- a/ide/idea/workspace.xml +++ b/ide/idea/workspace.xml @@ -143,7 +143,7 @@