You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/04/06 12:29:41 UTC

[GitHub] [ozone] bshashikant opened a new pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

bshashikant opened a new pull request #2116:
URL: https://github.com/apache/ozone/pull/2116


   ## What changes were proposed in this pull request?
   
   Added failover and retry logic based on exception received from server.
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-5050
   
   ## How was this patch tested?
   Will add UT.
   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] GlenGeng commented on a change in pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
GlenGeng commented on a change in pull request #2116:
URL: https://github.com/apache/ozone/pull/2116#discussion_r609661178



##########
File path: hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/proxy/SCMContainerLocationFailoverProxyProvider.java
##########
@@ -180,14 +181,22 @@ public synchronized void close() throws IOException {
     }
   }
 
-  public synchronized RetryPolicy.RetryAction getRetryAction(int failovers) {
-    if (failovers >= maxRetryCount) {
+  public RetryPolicy.RetryAction getRetryAction(int failovers, int retry,
+      Exception e) {
+    if (SCMHAUtils.isRetriableWithNoFailoverException(e)) {

Review comment:
       by the way, can this method replaced with `SCMHAUtils#getRetryAction` ?




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] bshashikant commented on a change in pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
bshashikant commented on a change in pull request #2116:
URL: https://github.com/apache/ozone/pull/2116#discussion_r609467785



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/StorageContainerLocationProtocolServerSideTranslatorPB.java
##########
@@ -329,6 +331,9 @@ public ScmContainerLocationResponse processRequest(
             "Unknown command type: " + request.getCmdType());
       }
     } catch (IOException e) {
+      if (SCMHAUtils.isRetriableWithNoFailoverException(e)) {

Review comment:
       > Given client side has already done the check, the server side can just return a `ServiceException` containing the real exception.
   
   The Service exception is not thrown for all exceptions back from server. Only for certain exceptions, it throws service exception. Only StorageContainerLocation server seems to be sending back service exception back to client for each failure. I have remove the check in StorageContainerLocationServer.
   




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] GlenGeng commented on a change in pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
GlenGeng commented on a change in pull request #2116:
URL: https://github.com/apache/ozone/pull/2116#discussion_r609351035



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/StorageContainerLocationProtocolServerSideTranslatorPB.java
##########
@@ -329,6 +331,9 @@ public ScmContainerLocationResponse processRequest(
             "Unknown command type: " + request.getCmdType());
       }
     } catch (IOException e) {
+      if (SCMHAUtils.isRetriableWithNoFailoverException(e)) {

Review comment:
       Given client side has already done the check, the server side can just return a `ServiceException` containing the real exception.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] bshashikant commented on a change in pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
bshashikant commented on a change in pull request #2116:
URL: https://github.com/apache/ozone/pull/2116#discussion_r609455927



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/StorageContainerLocationProtocolServerSideTranslatorPB.java
##########
@@ -329,6 +331,9 @@ public ScmContainerLocationResponse processRequest(
             "Unknown command type: " + request.getCmdType());
       }
     } catch (IOException e) {
+      if (SCMHAUtils.isRetriableWithNoFailoverException(e)) {

Review comment:
       > Given client side has already done the check, the server side can just return a `ServiceException` containing the real exception.
   
   The check is required because for only certain exceptions , we throw ServiceException. For others, it sets an error code instead of throwing a service exception.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] bshashikant commented on a change in pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
bshashikant commented on a change in pull request #2116:
URL: https://github.com/apache/ozone/pull/2116#discussion_r609455927



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/StorageContainerLocationProtocolServerSideTranslatorPB.java
##########
@@ -329,6 +331,9 @@ public ScmContainerLocationResponse processRequest(
             "Unknown command type: " + request.getCmdType());
       }
     } catch (IOException e) {
+      if (SCMHAUtils.isRetriableWithNoFailoverException(e)) {

Review comment:
       > Given client side has already done the check, the server side can just return a `ServiceException` containing the real exception.
   
   The check is required because for only certain exceptions , we throw ServiceException. For others, it sets an error code instead of throwing a service exception.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] GlenGeng commented on a change in pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
GlenGeng commented on a change in pull request #2116:
URL: https://github.com/apache/ozone/pull/2116#discussion_r609347653



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/StorageContainerLocationProtocolServerSideTranslatorPB.java
##########
@@ -329,6 +331,9 @@ public ScmContainerLocationResponse processRequest(
             "Unknown command type: " + request.getCmdType());
       }
     } catch (IOException e) {
+      if (SCMHAUtils.isRetriableWithNoFailoverException(e)) {

Review comment:
       Do we need this `RetriableWithNoFailoverException` ? 
   Say a `ServiceException` containing `ReconfigurationInProgressException` should return `true` by `isRetriableWithNoFailoverException`.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] bshashikant commented on a change in pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
bshashikant commented on a change in pull request #2116:
URL: https://github.com/apache/ozone/pull/2116#discussion_r609467785



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/StorageContainerLocationProtocolServerSideTranslatorPB.java
##########
@@ -329,6 +331,9 @@ public ScmContainerLocationResponse processRequest(
             "Unknown command type: " + request.getCmdType());
       }
     } catch (IOException e) {
+      if (SCMHAUtils.isRetriableWithNoFailoverException(e)) {

Review comment:
       > Given client side has already done the check, the server side can just return a `ServiceException` containing the real exception.
   
   The Service exception is not thrown for all exceptions back from server. Only for certain exceptions, it throws service exception. Only StorageContainerLocation server seems to be sending back service exception back to client for each failure. I have removed the check in StorageContainerLocationServer.
   




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] bshashikant commented on a change in pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
bshashikant commented on a change in pull request #2116:
URL: https://github.com/apache/ozone/pull/2116#discussion_r609452569



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/StorageContainerLocationProtocolServerSideTranslatorPB.java
##########
@@ -329,6 +331,9 @@ public ScmContainerLocationResponse processRequest(
             "Unknown command type: " + request.getCmdType());
       }
     } catch (IOException e) {
+      if (SCMHAUtils.isRetriableWithNoFailoverException(e)) {

Review comment:
       > Do we want to address the suggested leader in a new Jira?
   
   Yes, it will be addressed in a separate jira.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] GlenGeng commented on a change in pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
GlenGeng commented on a change in pull request #2116:
URL: https://github.com/apache/ozone/pull/2116#discussion_r609351353



##########
File path: hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/proxy/SCMContainerLocationFailoverProxyProvider.java
##########
@@ -180,14 +181,22 @@ public synchronized void close() throws IOException {
     }
   }
 
-  public synchronized RetryPolicy.RetryAction getRetryAction(int failovers) {
-    if (failovers >= maxRetryCount) {
+  public RetryPolicy.RetryAction getRetryAction(int failovers, int retry,
+      Exception e) {
+    if (SCMHAUtils.isRetriableWithNoFailoverException(e)) {
+      if (retry < maxRetryCount) {
+        return new RetryPolicy.RetryAction(
+            RetryPolicy.RetryAction.RetryDecision.RETRY, getRetryInterval());
+      } else {
+        return RetryPolicy.RetryAction.FAIL;
+      }
+    } else if (failovers < maxRetryCount) {

Review comment:
       Please change it too.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] GlenGeng commented on a change in pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
GlenGeng commented on a change in pull request #2116:
URL: https://github.com/apache/ozone/pull/2116#discussion_r608321313



##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/ha/RetriableWithNoFailoverException.java
##########
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hdds.scm.ha;
+
+import java.io.IOException;
+
+public class RetriableWithNoFailoverException  extends IOException {

Review comment:
       one space before `extends`

##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAUtils.java
##########
@@ -50,6 +55,14 @@ private SCMHAUtils() {
     // not used
   }
 
+  private static final List<Class<? extends Exception>> EXCEPTION_LIST =
+      ImmutableList.<Class<? extends Exception>>builder()
+          .add(LeaderNotReadyException.class)
+          .add(ReconfigurationInProgressException.class)
+          .add(ResourceUnavailableException.class)
+          .add(ReconfigurationTimeoutException.class)

Review comment:
       move `ReconfigurationTimeoutException` ahead of `ResourceUnavailableException`.
   
   Move `EXCEPTION_LIST` ahead of the private Ctor, better declare all member variables ahead of all member functions.

##########
File path: hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/proxy/SCMBlockLocationFailoverProxyProvider.java
##########
@@ -257,8 +249,11 @@ public RetryPolicy getSCMBlockLocationRetryPolicy(String newLeader) {
       @Override
       public RetryAction shouldRetry(Exception e, int retry,
                                      int failover, boolean b) {
-        performFailoverToAssignedLeader(newLeader);
-        return getRetryAction(failover);
+        if (!SCMHAUtils.isRetriableWithNoFailoverException(e)) {
+          performFailoverToAssignedLeader(newLeader);
+        }
+        return SCMHAUtils.getRetryAction(failover, retry, e, maxRetryCount,

Review comment:
       It is weird here that `SCMHAUtils.getRetryAction` does not handle conditions that `SCMHAUtils.isRetriableWithNoFailoverException(e)` is true.

##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAUtils.java
##########
@@ -50,6 +55,14 @@ private SCMHAUtils() {
     // not used
   }
 
+  private static final List<Class<? extends Exception>> EXCEPTION_LIST =

Review comment:
       `EXCEPTION_LIST` -> `RETRIABLE_WITH_NO_FAILOVER_EXCEPTION_LIST`
   
   and update function name `getExceptionList` too.

##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAUtils.java
##########
@@ -184,4 +197,42 @@ public static OzoneConfiguration removeSelfId(
     String scmServiceId = getScmServiceId(configuration);
     return getSCMNodeIds(configuration, scmServiceId);
   }
+
+  // This will return the underlying exception after unwrapping
+  // the exception to see if it matches with expected exception
+  // list , returns true otherwise will return false.
+  public static boolean isRetriableWithNoFailoverException(Exception e) {
+    Throwable t = e;
+    while (t != null && t.getCause() != null) {
+      for (Class<? extends Exception> cls : getExceptionList()) {

Review comment:
       better use `clazz` instead of `cls`.

##########
File path: hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/proxy/SCMContainerLocationFailoverProxyProvider.java
##########
@@ -180,14 +181,22 @@ public synchronized void close() throws IOException {
     }
   }
 
-  public synchronized RetryPolicy.RetryAction getRetryAction(int failovers) {
-    if (failovers >= maxRetryCount) {
+  public RetryPolicy.RetryAction getRetryAction(int failovers, int retry,
+      Exception e) {
+    if (SCMHAUtils.isRetriableWithNoFailoverException(e)) {
+      if (retry < maxRetryCount) {
+        return new RetryPolicy.RetryAction(
+            RetryPolicy.RetryAction.RetryDecision.RETRY, getRetryInterval());
+      } else {
+        return RetryPolicy.RetryAction.FAIL;
+      }
+    } else if (failovers < maxRetryCount) {

Review comment:
       as above. let's wrap `FAILOVER_AND_RETRY` and `FAIL` together for failover exception.




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] bshashikant commented on pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
bshashikant commented on pull request #2116:
URL: https://github.com/apache/ozone/pull/2116#issuecomment-816364188


   Committing this. Will take care of other suggested changes in https://issues.apache.org/jira/browse/HDDS-5051.


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] bshashikant merged pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
bshashikant merged pull request #2116:
URL: https://github.com/apache/ozone/pull/2116


   


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] GlenGeng commented on pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
GlenGeng commented on pull request #2116:
URL: https://github.com/apache/ozone/pull/2116#issuecomment-815574350


   +1. Thanks for the clarification.


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] bshashikant commented on pull request #2116: HDDS-5050. Add retry policy for ratis requests in SCM HA.

Posted by GitBox <gi...@apache.org>.
bshashikant commented on pull request #2116:
URL: https://github.com/apache/ozone/pull/2116#issuecomment-815569782


   > Do we want to address the suggested leader in a new Jira?
   
   Yes.


-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org