Reputation: 1384
I am trying to understand what does
-XX:OnOutOfMemoryError='kill %p'
mean in the following command?
I am not sure what %p means?
exec /bin/bash -c "LD_LIBRARY_PATH="/usr/hdp/current/hadoop-client/lib/native:/usr/hdp/current/hadoop-client/lib/native/Linux-amd64-64:$LD_LIBRARY_PATH" $JAVA_HOME/bin/java -server -Xmx5120m '-DENVIRONMENT=pt' -Djava.io.tmpdir=$PWD/tmp '-Dspark.history.ui.port=18081' '-Dspark.driver.port=39112' -Dspark.yarn.app.container.log.dir=/hadoop/hdfs/drive5/hadoop/yarn/log/application_1539650094881_0116/container_e111_1539650094881_0116_01_000024 -XX:OnOutOfMemoryError='kill %p' org.apache.spark.executor.CoarseGrainedExecutorBackend --driver-url spark://[email protected]:39112 --executor-id 13 --hostname slave3.hadoop.tsl.com --cores 5 --app-id application_1539650094881_0116 --user-class-path file:$PWD/__app__.jar 1> /hadoop/hdfs/drive5/hadoop/yarn/log/application_1539650094881_0116/container_e111_1539650094881_0116_01_000024/stdout 2> /hadoop/hdfs/drive5/hadoop/yarn/log/application_1539650094881_0116/container_e111_1539650094881_0116_01_000024/stderr"
Upvotes: 2
Views: 1915
Reputation: 10433
This argument executes a OS command when an OutOfMemory error happens. It can be used to send alerts, collect diagnostics or to restart the application.
The JVM will replace %p
with the process ID (PID) of itself. In the specific case it allows to terminate the application in a OOM. This is typically a good idea because an OutOfMemory error might randomly interrupt a thread and there is not a good and reliable way to continue.
Since 8u92 this hack is no longer needed as there is a ExitOnOutOfMemory
option as discussed here: Java - shutting down on Out of Memory Error
Upvotes: 1
Reputation: 98600
%p
here is a placeholder for PID.
JVM will automatically substitute this with a process ID of a currently running Java process.
The option tells JVM kill itself when OutOfMemoryError occurs.
Upvotes: 4