Skip to content

Commit 397c266

Browse files
committed
Merge branch 'cassandra-5.0' into trunk
2 parents e768418 + c3b2303 commit 397c266

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@
236236
* Add the ability to disable bulk loading of SSTables (CASSANDRA-18781)
237237
* Clean up obsolete functions and simplify cql_version handling in cqlsh (CASSANDRA-18787)
238238
Merged from 5.0:
239+
* Heap dump should not be generated on handled exceptions (CASSANDRA-20974)
239240
* Fix range queries on early-open BTI files (CASSANDRA-20976)
240241
* Avoid re-initializing underlying iterator in LazilyInitializedUnfilteredRowIterator after closing (CASSANDRA-20972)
241242
* Flush SAI segment builder when current SSTable writer is switched (CASSANDRA-20752)

src/java/org/apache/cassandra/utils/HeapUtils.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.lang.management.ManagementFactory;
2525
import java.nio.file.FileStore;
2626
import java.nio.file.Path;
27-
import java.util.concurrent.TimeUnit;
2827
import java.util.concurrent.locks.Lock;
2928
import java.util.concurrent.locks.ReentrantLock;
3029
import javax.management.MBeanServer;
@@ -38,7 +37,6 @@
3837
import org.apache.cassandra.config.DatabaseDescriptor;
3938
import org.apache.cassandra.io.util.File;
4039
import org.apache.cassandra.io.util.PathUtils;
41-
import org.apache.cassandra.utils.NoSpamLogger.NoSpamLogStatement;
4240

4341
import static org.apache.cassandra.config.CassandraRelevantEnv.JAVA_HOME;
4442
import static org.apache.cassandra.utils.Clock.Global.currentTimeMillis;
@@ -50,7 +48,6 @@
5048
public final class HeapUtils
5149
{
5250
private static final Logger logger = LoggerFactory.getLogger(HeapUtils.class);
53-
private static final NoSpamLogStatement disabledStatement = NoSpamLogger.getStatement(logger, "Heap dump creation on uncaught exceptions is disabled.", 1L, TimeUnit.MINUTES);
5451

5552
private static final Lock DUMP_LOCK = new ReentrantLock();
5653

@@ -131,10 +128,6 @@ public static String maybeCreateHeapDump()
131128

132129
return fullPath;
133130
}
134-
else
135-
{
136-
disabledStatement.debug();
137-
}
138131
}
139132
catch (Throwable e)
140133
{

src/java/org/apache/cassandra/utils/JVMStabilityInspector.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static void uncaughtException(Thread thread, Throwable t)
7878
if (t2 != t && (t2 instanceof FSError || t2 instanceof CorruptSSTableException))
7979
logger.error("Exception in thread {}", thread, t2);
8080
}
81-
JVMStabilityInspector.inspectThrowable(t);
81+
inspectThrowable(t, DiskErrorsHandlerService.get()::inspectDiskError, true);
8282
}
8383

8484
/**
@@ -89,20 +89,20 @@ public static void uncaughtException(Thread thread, Throwable t)
8989
*/
9090
public static void inspectThrowable(Throwable t) throws OutOfMemoryError
9191
{
92-
inspectThrowable(t, DiskErrorsHandlerService.get()::inspectDiskError);
92+
inspectThrowable(t, DiskErrorsHandlerService.get()::inspectDiskError, false);
9393
}
9494

9595
public static void inspectCommitLogThrowable(Throwable t)
9696
{
97-
inspectThrowable(t, ex -> DiskErrorsHandlerService.get().inspectCommitLogError(ex));
97+
inspectThrowable(t, ex -> DiskErrorsHandlerService.get().inspectCommitLogError(ex), false);
9898
}
9999

100100
public static void inspectJournalThrowable(Throwable t, String journalName, FailurePolicy failurePolicy)
101101
{
102-
inspectThrowable(t, th -> inspectJournalError(th, journalName, failurePolicy));
102+
inspectThrowable(t, th -> inspectJournalError(th, journalName, failurePolicy), false);
103103
}
104104

105-
public static void inspectThrowable(Throwable t, Consumer<Throwable> fn) throws OutOfMemoryError
105+
public static void inspectThrowable(Throwable t, Consumer<Throwable> fn, boolean isUncaughtException) throws OutOfMemoryError
106106
{
107107
boolean isUnstable = false;
108108
if (t instanceof OutOfMemoryError)
@@ -136,13 +136,17 @@ else if (t instanceof UnrecoverableIllegalStateException)
136136
}
137137

138138
// Anything other than an OOM, we should try and heap dump to capture what's going on if configured to do so
139-
try
140-
{
141-
HeapUtils.maybeCreateHeapDump();
142-
}
143-
catch (Throwable sub)
139+
if (isUncaughtException && DatabaseDescriptor.getDumpHeapOnUncaughtException())
144140
{
145-
t.addSuppressed(sub);
141+
try
142+
{
143+
// Avoid entering maybeCreateHeapDump unless the setting is enabled to avoid expensive lock
144+
HeapUtils.maybeCreateHeapDump();
145+
}
146+
catch (Throwable sub)
147+
{
148+
t.addSuppressed(sub);
149+
}
146150
}
147151

148152
if (t instanceof InterruptedException)
@@ -177,7 +181,7 @@ else if (t instanceof UnrecoverableIllegalStateException)
177181
}
178182

179183
if (t.getCause() != null)
180-
inspectThrowable(t.getCause(), fn);
184+
inspectThrowable(t.getCause(), fn, isUncaughtException);
181185
}
182186

183187
private static final Set<String> FORCE_HEAP_OOM_IGNORE_SET = ImmutableSet.of("Java heap space", "GC Overhead limit exceeded");

0 commit comments

Comments
 (0)