Apache9 commented on code in PR #5275:
URL: https://github.com/apache/hbase/pull/5275#discussion_r1235326486


##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java:
##########
@@ -465,27 +465,40 @@ private void onError(Map<byte[], RegionRequest> 
actionsByRegion, int tries, Thro
     List<Action> copiedActions = actionsByRegion.values().stream().flatMap(r 
-> r.actions.stream())
       .collect(Collectors.toList());
     addError(copiedActions, error, serverName);
-    tryResubmit(copiedActions.stream(), tries, error instanceof 
RetryImmediatelyException,
-      HBaseServerException.isServerOverloaded(error));
+    tryResubmit(copiedActions.stream(), tries, error instanceof 
RetryImmediatelyException, error);
   }
 
   private void tryResubmit(Stream<Action> actions, int tries, boolean 
immediately,
-    boolean isServerOverloaded) {
+    Throwable error) {
     if (immediately) {
       groupAndSend(actions, tries);
       return;
     }
+
+    boolean isServerOverloaded = 
HBaseServerException.isServerOverloaded(error);
+    OptionalLong maybePauseNsToUse =
+      pauseManager.getPauseNsFromException(error, remainingTimeNs() - 
SLEEP_DELTA_NS);
+    if (!maybePauseNsToUse.isPresent()) {
+      failAll(actions, tries);
+      return;
+    }
+    long pauseNsToUse = maybePauseNsToUse.getAsLong();
+    if (!(error instanceof RpcThrottlingException)) {
+      // RpcThrottlingException tells us exactly how long the client should 
wait for,
+      // so we should not factor in the retry count for said exception
+      pauseNsToUse = getPauseTime(pauseNsToUse, tries - 1);
+    }
+
     long delayNs;
-    long pauseNsToUse = isServerOverloaded ? pauseNsForServerOverloaded : 
pauseNs;
     if (operationTimeoutNs > 0) {
       long maxDelayNs = remainingTimeNs() - SLEEP_DELTA_NS;
       if (maxDelayNs <= 0) {
         failAll(actions, tries);
         return;
       }
-      delayNs = Math.min(maxDelayNs, getPauseTime(pauseNsToUse, tries - 1));
+      delayNs = Math.min(maxDelayNs, pauseNsToUse);
     } else {
-      delayNs = getPauseTime(pauseNsToUse, tries - 1);
+      delayNs = pauseNsToUse;
     }
 
     if (isServerOverloaded) {

Review Comment:
   Seems we only need isServerOverloaded here?



##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java:
##########
@@ -465,27 +465,40 @@ private void onError(Map<byte[], RegionRequest> 
actionsByRegion, int tries, Thro
     List<Action> copiedActions = actionsByRegion.values().stream().flatMap(r 
-> r.actions.stream())
       .collect(Collectors.toList());
     addError(copiedActions, error, serverName);
-    tryResubmit(copiedActions.stream(), tries, error instanceof 
RetryImmediatelyException,
-      HBaseServerException.isServerOverloaded(error));
+    tryResubmit(copiedActions.stream(), tries, error instanceof 
RetryImmediatelyException, error);
   }
 
   private void tryResubmit(Stream<Action> actions, int tries, boolean 
immediately,
-    boolean isServerOverloaded) {
+    Throwable error) {
     if (immediately) {
       groupAndSend(actions, tries);
       return;
     }
+
+    boolean isServerOverloaded = 
HBaseServerException.isServerOverloaded(error);
+    OptionalLong maybePauseNsToUse =
+      pauseManager.getPauseNsFromException(error, remainingTimeNs() - 
SLEEP_DELTA_NS);

Review Comment:
   Let's just pass the `tries` to this method so it could return the delayNs 
directly? The instanceof below seems strange...



##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java:
##########
@@ -465,27 +465,40 @@ private void onError(Map<byte[], RegionRequest> 
actionsByRegion, int tries, Thro
     List<Action> copiedActions = actionsByRegion.values().stream().flatMap(r 
-> r.actions.stream())
       .collect(Collectors.toList());
     addError(copiedActions, error, serverName);
-    tryResubmit(copiedActions.stream(), tries, error instanceof 
RetryImmediatelyException,
-      HBaseServerException.isServerOverloaded(error));
+    tryResubmit(copiedActions.stream(), tries, error instanceof 
RetryImmediatelyException, error);
   }
 
   private void tryResubmit(Stream<Action> actions, int tries, boolean 
immediately,
-    boolean isServerOverloaded) {
+    Throwable error) {
     if (immediately) {
       groupAndSend(actions, tries);
       return;
     }
+
+    boolean isServerOverloaded = 
HBaseServerException.isServerOverloaded(error);

Review Comment:
   Do we need to test this here? 



##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java:
##########
@@ -465,27 +465,40 @@ private void onError(Map<byte[], RegionRequest> 
actionsByRegion, int tries, Thro
     List<Action> copiedActions = actionsByRegion.values().stream().flatMap(r 
-> r.actions.stream())
       .collect(Collectors.toList());
     addError(copiedActions, error, serverName);
-    tryResubmit(copiedActions.stream(), tries, error instanceof 
RetryImmediatelyException,
-      HBaseServerException.isServerOverloaded(error));
+    tryResubmit(copiedActions.stream(), tries, error instanceof 
RetryImmediatelyException, error);
   }
 
   private void tryResubmit(Stream<Action> actions, int tries, boolean 
immediately,
-    boolean isServerOverloaded) {
+    Throwable error) {
     if (immediately) {
       groupAndSend(actions, tries);
       return;
     }
+
+    boolean isServerOverloaded = 
HBaseServerException.isServerOverloaded(error);
+    OptionalLong maybePauseNsToUse =
+      pauseManager.getPauseNsFromException(error, remainingTimeNs() - 
SLEEP_DELTA_NS);
+    if (!maybePauseNsToUse.isPresent()) {
+      failAll(actions, tries);
+      return;
+    }
+    long pauseNsToUse = maybePauseNsToUse.getAsLong();
+    if (!(error instanceof RpcThrottlingException)) {
+      // RpcThrottlingException tells us exactly how long the client should 
wait for,
+      // so we should not factor in the retry count for said exception
+      pauseNsToUse = getPauseTime(pauseNsToUse, tries - 1);

Review Comment:
   I think this meas the pauseNsToUse is just delayNs now?



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

Reply via email to