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 8b9214c2c45 Fix the logic of catch ServerNotReadyException to enable 
read retry (#13509) (#13513)
8b9214c2c45 is described below

commit 8b9214c2c4585075aeb8f1df5b16e5bd06e90122
Author: Xiangpeng Hu <[email protected]>
AuthorDate: Fri Sep 13 19:51:02 2024 +0800

    Fix the logic of catch ServerNotReadyException to enable read retry 
(#13509) (#13513)
    
    (cherry picked from commit 3f4fa64c5a6a62d3dc77dc1838f9ab5729df77c9)
---
 .../java/org/apache/iotdb/consensus/ratis/RatisConsensus.java    | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git 
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
 
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
index 3bf52b11f99..85786cc7087 100644
--- 
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
+++ 
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
@@ -78,6 +78,7 @@ import org.apache.ratis.protocol.exceptions.RaftException;
 import org.apache.ratis.protocol.exceptions.ReadException;
 import org.apache.ratis.protocol.exceptions.ReadIndexException;
 import org.apache.ratis.protocol.exceptions.ResourceUnavailableException;
+import org.apache.ratis.protocol.exceptions.ServerNotReadyException;
 import org.apache.ratis.server.DivisionInfo;
 import org.apache.ratis.server.RaftServer;
 import org.apache.ratis.server.RaftServerConfigKeys;
@@ -381,6 +382,14 @@ class RatisConsensus implements IConsensus {
       }
     } catch (GroupMismatchException e) {
       throw new ConsensusGroupNotExistException(groupId);
+    } catch (IllegalStateException e) {
+      if (e.getMessage() != null && 
e.getMessage().contains("ServerNotReadyException")) {
+        ServerNotReadyException serverNotReadyException =
+            new ServerNotReadyException(e.getMessage());
+        throw new RatisReadUnavailableException(serverNotReadyException);
+      } else {
+        throw new RatisRequestFailedException(e);
+      }
     } catch (Exception e) {
       throw new RatisRequestFailedException(e);
     }

Reply via email to