tillrohrmann commented on a change in pull request #9703: [FLINK-14038]Add 
default GC options for flink on yarn to facilitate debugging
URL: https://github.com/apache/flink/pull/9703#discussion_r337641855
 
 

 ##########
 File path: 
flink-yarn/src/main/java/org/apache/flink/yarn/YarnClusterDescriptor.java
 ##########
 @@ -1588,16 +1589,52 @@ private void 
addPluginsFoldersToShipFiles(Collection<File> effectiveShipFiles) {
                }
        }
 
-       ContainerLaunchContext setupApplicationMasterContainer(
+       protected ContainerLaunchContext setupApplicationMasterContainer(
+                       String appId,
                        String yarnClusterEntrypoint,
                        boolean hasLogback,
                        boolean hasLog4j,
                        boolean hasKrb5,
                        int jobManagerMemoryMb) {
                // ------------------ Prepare Application Master Container  
------------------------------
 
+               String javaOpts = "";
+               // Add default gc logging options if enabled
+               boolean enableGCLogging = 
flinkConfiguration.getBoolean(CoreOptions.FLINK_JVM_DEFAULT_GC_LOGGING);
+               if (enableGCLogging) {
+                       String defaultGCOptions =
+                               "-Xloggc:" + 
ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/gc.log " +
+                                       "-XX:+PrintGCApplicationStoppedTime " +
+                                       "-XX:+PrintGCDetails " +
+                                       "-XX:+PrintGCDateStamps " +
+                                       "-XX:+UseGCLogFileRotation " +
+                                       "-XX:NumberOfGCLogFiles=10 " +
+                                       "-XX:GCLogFileSize=10M " +
+                                       "-XX:+PrintPromotionFailure " +
+                                       "-XX:+PrintGCCause";
+                       javaOpts += defaultGCOptions;
+               }
+               // Add default heap dump options if enabled
+               boolean enableHeapDump = 
flinkConfiguration.getBoolean(CoreOptions.FLINK_JVM_HEAPDUMP_ON_OOM);
+               String heapdumpDir = 
flinkConfiguration.getString(CoreOptions.FLINK_JVM_HEAPDUMP_DIRECTORY);
+               if (enableHeapDump) {
+                       String dumpFileName = "flink-jm-heapdump.hprof";
+                       String dumpFileDestPath = new File(heapdumpDir, appId + 
"-" + dumpFileName).getAbsolutePath();
+                       String oomScript = String.format("echo -e 
'OutOfMemoryError! Killing current process %%p...\n" +
+                                       "Check gc logs and heapdump file(%s) 
for details.' > " +
+                                       
ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/jobmanager.err; " +
+                                       "kill -9 %%p",
+                               dumpFileDestPath);
+                       javaOpts += String.format(
+                               " -XX:+HeapDumpOnOutOfMemoryError " +
+                                       "-XX:HeapDumpPath=%s " +
+                                       "-XX:OnOutOfMemoryError=\"%s\"",
+                               dumpFileDestPath,
+                               oomScript);
+               }
 
 Review comment:
   Can we deduplicate this logic wrt `BootstrapTools`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to