You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ta...@apache.org on 2024/05/20 08:31:56 UTC

(iotdb) branch fix_ratis_recover_failure created (now 709735d1970)

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

tanxinyu pushed a change to branch fix_ratis_recover_failure
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 709735d1970 fix

This branch includes the following new commits:

     new 709735d1970 fix

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(iotdb) 01/01: fix

Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 709735d1970203dffc820b301e5867d812e79189
Author: OneSizeFitQuorum <ta...@apache.org>
AuthorDate: Mon May 20 16:31:36 2024 +0800

    fix
    
    Signed-off-by: OneSizeFitQuorum <ta...@apache.org>
---
 .../java/org/apache/iotdb/consensus/ratis/RatisConsensus.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

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 de646de2334..235556ccced 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
@@ -115,8 +115,8 @@ class RatisConsensus implements IConsensus {
   private final RaftPeer myself;
 
   private final File storageDir;
-
-  private final RaftServer server;
+  private final RaftServer.Builder serverBuilder;
+  private RaftServer server;
 
   private final RaftProperties properties = new RaftProperties();
   private final RaftClientRpc clientRpc;
@@ -195,7 +195,8 @@ class RatisConsensus implements IConsensus {
 
     clientRpc = new GrpcFactory(new Parameters()).newRaftClientRpc(ClientId.randomId(), properties);
 
-    server =
+    // do not build server in constructor in case stateMachine is not ready
+    serverBuilder =
         RaftServer.newBuilder()
             .setServerId(myself.getId())
             .setProperties(properties)
@@ -205,12 +206,12 @@ class RatisConsensus implements IConsensus {
                     new ApplicationStateMachineProxy(
                         registry.apply(Utils.fromRaftGroupIdToConsensusGroupId(raftGroupId)),
                         raftGroupId,
-                        this::onLeaderChanged))
-            .build();
+                        this::onLeaderChanged));
   }
 
   @Override
   public synchronized void start() throws IOException {
+    server = serverBuilder.build();
     MetricService.getInstance().addMetricSet(this.ratisMetricSet);
     server.start();
     registerAndStartDiskGuardian();