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/07 07:15:11 UTC

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

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