Skip to content

Commit

Permalink
Enable exit on out of memory error (#71542)
Browse files Browse the repository at this point in the history
Rather than rely on ElasticsearchUncaughtExceptionHandler, it is safer
to use the JVM's built-in support for terminating the process on OOM.
  • Loading branch information
henningandersen committed Oct 7, 2021
1 parent ac76063 commit 2e8ac06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions distribution/src/config/jvm.options
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
# specified
-XX:+HeapDumpOnOutOfMemoryError

# exit right after heap dump on out of memory error. Recommended to also use
# on java 8 for supported versions (8u92+).
9-:-XX:+ExitOnOutOfMemoryError

# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
@heap.dump.path@
Expand Down
3 changes: 3 additions & 0 deletions test/external-modules/die-with-dignity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ tasks.named("javaRestTest").configure {

testClusters.matching { it.name == "javaRestTest" }.configureEach {
systemProperty "die.with.dignity.test", "true"
// disable exit on out of memory error to let DieWithDignityIT verify that OOM handling without that works (including OOMs that are not caused by
// memory like native threads. We leave it to the JVM to test that exit on OOM works via the flag.
jvmArgs '-XX:-ExitOnOutOfMemoryError'
}

tasks.named("test").configure {
Expand Down

0 comments on commit 2e8ac06

Please sign in to comment.