Skip to content

Commit b4d33c5

Browse files
authored
[Cherrypick] Configure JVM so that it exits upon OutOfMemoryError originating in JVM (#38567) (#38582)
1 parent c372714 commit b4d33c5

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

sdks/java/container/boot.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,6 @@ func main() {
195195
"-XX:+UseParallelGC",
196196
"-XX:+AlwaysActAsServerClassMachine",
197197
"-XX:-OmitStackTraceInFastThrow",
198-
// Crash and restart instead of throwing OutOfMemoryError which may be caught by user or
199-
// framework code and leave things in a degraded state.
200-
"-XX:+ExitOnOutOfMemoryError",
201198
}
202199

203200
enableGoogleCloudProfiler := strings.Contains(options, enableGoogleCloudProfilerOption)
@@ -227,18 +224,16 @@ func main() {
227224
args = append(args, jammAgentArgs)
228225
}
229226

230-
enableHeapDumpsOnOom := false
231227
// If heap dumping is enabled, configure the JVM to dump it on oom events.
232228
if pipelineOptions, ok := info.GetPipelineOptions().GetFields()["options"]; ok {
233229
if heapDumpOption, ok := pipelineOptions.GetStructValue().GetFields()["enableHeapDumps"]; ok {
234-
enableHeapDumpsOnOom = heapDumpOption.GetBoolValue()
230+
if heapDumpOption.GetBoolValue() {
231+
args = append(args, "-XX:+HeapDumpOnOutOfMemoryError",
232+
"-Dbeam.fn.heap_dump_dir="+filepath.Join(dir, "heapdumps"),
233+
"-XX:HeapDumpPath="+filepath.Join(dir, "heapdumps", "heap_dump.hprof"))
234+
}
235235
}
236236
}
237-
if enableHeapDumpsOnOom {
238-
args = append(args, "-XX:+HeapDumpOnOutOfMemoryError",
239-
"-Dbeam.fn.heap_dump_dir="+filepath.Join(dir, "heapdumps"),
240-
"-XX:HeapDumpPath="+filepath.Join(dir, "heapdumps", "heap_dump.hprof"))
241-
}
242237

243238
// Apply meta options
244239
const metaDir = "/opt/apache/beam/options"

0 commit comments

Comments
 (0)