This is an automated email from the ASF dual-hosted git repository.

tanxinyu pushed a commit to branch rc/1.3.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rc/1.3.3 by this push:
     new 9f5022fccd4 [Fix] Add another retryPolicy for RatisClient (#13286) 
(#13287)
9f5022fccd4 is described below

commit 9f5022fccd43afb31864663e132a7864671dfe92
Author: 133tosakarin <[email protected]>
AuthorDate: Mon Aug 26 10:09:25 2024 +0800

    [Fix] Add another retryPolicy for RatisClient (#13286) (#13287)
---
 .../apache/iotdb/consensus/ratis/RatisClient.java  | 28 ++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git 
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisClient.java
 
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisClient.java
index 7c03ddf042e..7f0565e782e 100644
--- 
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisClient.java
+++ 
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisClient.java
@@ -158,7 +158,7 @@ class RatisClient implements AutoCloseable {
               RaftClient.newBuilder()
                   .setProperties(raftProperties)
                   .setRaftGroup(group)
-                  .setRetryPolicy(new RatisEndlessRetryPolicy())
+                  .setRetryPolicy(new RatisEndlessRetryPolicy(config))
                   .setClientRpc(clientRpc)
                   .build(),
               clientManager));
@@ -222,24 +222,28 @@ class RatisClient implements AutoCloseable {
   private static class RatisEndlessRetryPolicy implements RetryPolicy {
 
     private static final Logger logger = 
LoggerFactory.getLogger(RatisEndlessRetryPolicy.class);
+    // for reconfiguration request, we use different retry policy
+    private final RetryPolicy endlessPolicy;
     private final RetryPolicy defaultPolicy;
 
-    RatisEndlessRetryPolicy() {
-      defaultPolicy =
+    RatisEndlessRetryPolicy(RatisConfig.Client config) {
+      endlessPolicy =
           RetryPolicies.retryForeverWithSleep(TimeDuration.valueOf(2, 
TimeUnit.SECONDS));
+      defaultPolicy = new RatisRetryPolicy(config);
     }
 
     @Override
     public Action handleAttemptFailure(Event event) {
-      if (event.getCause() == null
-          || event.getCause() instanceof ReconfigurationInProgressException
-          || event.getCause() instanceof TimeoutIOException
-          || event.getCause() instanceof LeaderSteppingDownException
-          || event.getCause() instanceof ReconfigurationTimeoutException
-          || event.getCause() instanceof ServerNotReadyException
-          || event.getCause() instanceof NotLeaderException
-          || event.getCause() instanceof LeaderNotReadyException) {
-        return defaultPolicy.handleAttemptFailure(event);
+      Throwable cause = event.getCause();
+      if (cause == null
+          || cause instanceof ReconfigurationInProgressException
+          || cause instanceof TimeoutIOException
+          || cause instanceof LeaderSteppingDownException
+          || cause instanceof ReconfigurationTimeoutException
+          || cause instanceof ServerNotReadyException
+          || cause instanceof NotLeaderException
+          || cause instanceof LeaderNotReadyException) {
+        return endlessPolicy.handleAttemptFailure(event);
       }
 
       return defaultPolicy.handleAttemptFailure(event);

Reply via email to