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 2022/12/13 02:37:15 UTC

[iotdb] 01/01: add judgement for ratis

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

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

commit e0b0d717e947973a1763582db25b4787e2ee2ced
Author: OneSizeFitQuorum <ta...@apache.org>
AuthorDate: Tue Dec 13 10:36:55 2022 +0800

    add judgement for ratis
    
    Signed-off-by: OneSizeFitQuorum <ta...@apache.org>
---
 .../java/org/apache/iotdb/db/service/IoTDBShutdownHook.java | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/service/IoTDBShutdownHook.java b/server/src/main/java/org/apache/iotdb/db/service/IoTDBShutdownHook.java
index 03a525406b..3f7fefee8c 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/IoTDBShutdownHook.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/IoTDBShutdownHook.java
@@ -19,6 +19,7 @@
 package org.apache.iotdb.db.service;
 
 import org.apache.iotdb.commons.conf.CommonDescriptor;
+import org.apache.iotdb.consensus.ConsensusFactory;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.conf.directories.DirectoryChecker;
 import org.apache.iotdb.db.consensus.DataRegionConsensusImpl;
@@ -54,9 +55,15 @@ public class IoTDBShutdownHook extends Thread {
     }
     WALManager.getInstance().deleteOutdatedWALFiles();
 
-    if (IoTDBDescriptor.getInstance().getConfig().isClusterMode()) {
-      // This setting ensures that compaction work is not discarded
-      // even if there are frequent restarts
+    // We did this work because the RatisConsensus recovery mechanism is different from other
+    // consensus algorithms, which will replace the underlying storage engine based on its own
+    // latest snapshot, while other consensus algorithms will not. This judgement ensures that
+    // compaction work is not discarded even if there are frequent restarts
+    if (IoTDBDescriptor.getInstance().getConfig().isClusterMode()
+        && IoTDBDescriptor.getInstance()
+            .getConfig()
+            .getDataRegionConsensusProtocolClass()
+            .equals(ConsensusFactory.RATIS_CONSENSUS)) {
       DataRegionConsensusImpl.getInstance()
           .getAllConsensusGroupIds()
           .parallelStream()