This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 3f4fa64c5a6 Fix the logic of catch ServerNotReadyException to enable
read retry (#13509)
3f4fa64c5a6 is described below
commit 3f4fa64c5a6a62d3dc77dc1838f9ab5729df77c9
Author: Xiangpeng Hu <[email protected]>
AuthorDate: Fri Sep 13 15:57:10 2024 +0800
Fix the logic of catch ServerNotReadyException to enable read retry (#13509)
---
.../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);
}