Skip to content

CASSANDRA-16939: Only remove shutdown hook for fatal heap OOMs#4691

Open
Shanzita wants to merge 2 commits intoapache:trunkfrom
Shanzita:CASSANDRA-16939-trunk
Open

CASSANDRA-16939: Only remove shutdown hook for fatal heap OOMs#4691
Shanzita wants to merge 2 commits intoapache:trunkfrom
Shanzita:CASSANDRA-16939-trunk

Conversation

@Shanzita
Copy link

Description:
CASSANDRA-16939: Only remove shutdown hook for fatal heap
OOMs

Previously, StorageService.removeShutdownHook() was
called unconditionally
for all OutOfMemoryErrors in
JVMStabilityInspector.inspectThrowable().
This removed the drain shutdown hook even for non-fatal
OOMs like
"Direct buffer memory" or "unable to create new native
thread", preventing
graceful shutdown afterward even though the JVM was
otherwise healthy.

The fix guards removeShutdownHook() with a new
isHeapSpaceOom() method
that reuses the existing FORCE_HEAP_OOM_IGNORE_SET to
only remove the hook
for fatal heap OOMs ("Java heap space", "GC Overhead limit
exceeded").

Changes:

  • JVMStabilityInspector.java: Guard
    removeShutdownHook() with isHeapSpaceOom() check
  • JVMStabilityInspectorTest.java: Added tests verifying
    shutdown hook is preserved
    for non-fatal OOMs and removed for fatal OOMs

Tests:

  • All existing tests pass (8/8, 0 failures)
  • Checkstyle clean (0 violations)

patch by Shanizta Siddiqua; reviewed by for
CASSANDRA-16939

@Shanzita Shanzita force-pushed the CASSANDRA-16939-trunk branch from 84be9a8 to e79db48 Compare March 26, 2026 04:28
  FORCE_HEAP_OOM_IGNORE_SET package-protected with
  @VisibleForTesting
@bschoening bschoening requested a review from Copilot March 27, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants