ferdelyi commented on code in PR #8222:
URL: https://github.com/apache/hadoop/pull/8222#discussion_r2748271721


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/conf/ZKConfigurationStore.java:
##########
@@ -263,10 +264,46 @@ private boolean createNewZkPath(String path) throws 
Exception {
     }
   }
 
+  /*
   @VisibleForTesting
   protected byte[] getZkData(String path) throws Exception {
     return zkManager.getData(path);
   }
+*/
+
+  @VisibleForTesting
+  protected byte[] getZkData(String path) throws Exception {
+    // Should a 'yarn resourcemanager -format-state-store' command is issued
+    // while one of the RM is in a starting state, there is a time period
+    // when the /confstore/CONF_STORE path does not exist, hence the
+    // getZkData method returns a null value causing the RM to fail.
+    // To prevent this, added a re-try mechanism before giving up.
+    int maxRetries = 6;
+    int attempt = 1;
+    int sleepBetweenRetries = conf.getInt(
+        YarnConfiguration.RM_SCHEDCONF_STORE_ZK_READ_RETRY_SECS,
+        YarnConfiguration.DEFAULT_RM_SCHEDCONF_STORE_ZK_READ_RETRY_SECS);
+
+    while (attempt < maxRetries) {
+
+        if(zkManager.exists(path)) {
+          LOG.debug("zkManager.exists(path) {} exists.", path);
+          byte[] zkData = zkManager.getData(path);
+          // If we found data, return immediately

Review Comment:
   You are right, thank you!



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to