You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2022/11/29 13:23:13 UTC

[iotdb] branch rel/1.0 updated: [To rel/1.0] Ratis disk usage control (#8202)

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

qiaojialin pushed a commit to branch rel/1.0
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/1.0 by this push:
     new 80e97a4938 [To rel/1.0] Ratis disk usage control (#8202)
80e97a4938 is described below

commit 80e97a4938875f049102fe2b842727fe490ed1a2
Author: William Song <48...@users.noreply.github.com>
AuthorDate: Tue Nov 29 21:23:06 2022 +0800

    [To rel/1.0] Ratis disk usage control (#8202)
---
 .../iotdb/confignode/conf/ConfigNodeConfig.java    | 28 +++++++++++++
 .../confignode/conf/ConfigNodeDescriptor.java      | 30 ++++++++++++++
 .../iotdb/confignode/manager/ConsensusManager.java |  2 +
 .../iotdb/confignode/manager/node/NodeManager.java |  3 ++
 .../org/apache/iotdb/consensus/common/Utils.java   | 33 +++++++++++++++
 .../apache/iotdb/consensus/config/RatisConfig.java | 36 +++++++++++++++-
 .../iotdb/consensus/ratis/RatisConsensus.java      | 48 ++++++++++++++++++++++
 .../iotdb/consensus/ratis/RatisConsensusTest.java  | 11 ++++-
 .../resources/conf/iotdb-common.properties         |  5 +++
 .../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 19 +++++++++
 .../org/apache/iotdb/db/conf/IoTDBDescriptor.java  |  3 ++
 .../db/consensus/DataRegionConsensusImpl.java      |  2 +
 .../db/consensus/SchemaRegionConsensusImpl.java    |  2 +
 .../src/main/thrift/confignode.thrift              |  3 ++
 14 files changed, 222 insertions(+), 3 deletions(-)

diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java
index bf64d56565..127a2c3680 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeConfig.java
@@ -262,6 +262,10 @@ public class ConfigNodeConfig {
   private long ratisFirstElectionTimeoutMinMs = 50;
   private long ratisFirstElectionTimeoutMaxMs = 150;
 
+  private long configNodeRatisLogMaxMB = 2 * 1024;
+  private long schemaRegionRatisLogMaxMB = 2 * 1024;
+  private long dataRegionRatisLogMaxMB = 20 * 1024;
+
   public ConfigNodeConfig() {
     // empty constructor
   }
@@ -1019,4 +1023,28 @@ public class ConfigNodeConfig {
   public void setRatisFirstElectionTimeoutMaxMs(long ratisFirstElectionTimeoutMaxMs) {
     this.ratisFirstElectionTimeoutMaxMs = ratisFirstElectionTimeoutMaxMs;
   }
+
+  public long getConfigNodeRatisLogMaxMB() {
+    return configNodeRatisLogMaxMB;
+  }
+
+  public void setConfigNodeRatisLogMaxMB(long configNodeRatisLogMaxMB) {
+    this.configNodeRatisLogMaxMB = configNodeRatisLogMaxMB;
+  }
+
+  public long getSchemaRegionRatisLogMaxMB() {
+    return schemaRegionRatisLogMaxMB;
+  }
+
+  public void setSchemaRegionRatisLogMaxMB(long schemaRegionRatisLogMaxMB) {
+    this.schemaRegionRatisLogMaxMB = schemaRegionRatisLogMaxMB;
+  }
+
+  public long getDataRegionRatisLogMaxMB() {
+    return dataRegionRatisLogMaxMB;
+  }
+
+  public void setDataRegionRatisLogMaxMB(long dataRegionRatisLogMaxMB) {
+    this.dataRegionRatisLogMaxMB = dataRegionRatisLogMaxMB;
+  }
 }
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
index a7dea60660..e6973e259b 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
@@ -716,6 +716,36 @@ public class ConfigNodeDescriptor {
                     "ratis_first_election_timeout_max_ms",
                     String.valueOf(conf.getRatisFirstElectionTimeoutMaxMs()))
                 .trim()));
+
+    conf.setConfigNodeRatisLogMaxMB(
+        Long.parseLong(
+                properties
+                    .getProperty(
+                        "config_node_ratis_log_max_size_mb",
+                        String.valueOf(conf.getConfigNodeRatisLogMaxMB()))
+                    .trim())
+            / 1024
+            / 1024);
+
+    conf.setSchemaRegionRatisLogMaxMB(
+        Long.parseLong(
+                properties
+                    .getProperty(
+                        "schema_region_ratis_log_max_size_mb",
+                        String.valueOf(conf.getSchemaRegionRatisLogMaxMB()))
+                    .trim())
+            / 1024
+            / 1024);
+
+    conf.setDataRegionRatisLogMaxMB(
+        Long.parseLong(
+                properties
+                    .getProperty(
+                        "data_region_ratis_log_max_size_mb",
+                        String.valueOf(conf.getDataRegionRatisLogMaxMB()))
+                    .trim())
+            / 1024
+            / 1024);
   }
 
   private void loadCQConfig(Properties properties) {
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConsensusManager.java b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConsensusManager.java
index 7e9c392e8b..5b95787136 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConsensusManager.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConsensusManager.java
@@ -165,6 +165,8 @@ public class ConsensusManager {
                                           CONF.getConfigNodeRatisInitialSleepTimeMs())
                                       .setClientRetryMaxSleepTimeMs(
                                           CONF.getConfigNodeRatisMaxSleepTimeMs())
+                                      .setTriggerSnapshotFileSize(
+                                          CONF.getConfigNodeRatisLogMaxMB() * 1024 * 1024)
                                       .build())
                               .build())
                       .setStorageDir(CONF.getConsensusDir())
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java b/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java
index a0ace133de..a83ae0212d 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java
@@ -209,6 +209,9 @@ public class NodeManager {
     ratisConfig.setFirstElectionTimeoutMin(conf.getRatisFirstElectionTimeoutMinMs());
     ratisConfig.setFirstElectionTimeoutMax(conf.getRatisFirstElectionTimeoutMaxMs());
 
+    ratisConfig.setSchemaRegionRatisLogMax(conf.getSchemaRegionRatisLogMaxMB());
+    ratisConfig.setDataRegionRatisLogMax(conf.getDataRegionRatisLogMaxMB());
+
     dataSet.setRatisConfig(ratisConfig);
   }
 
diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/common/Utils.java b/consensus/src/main/java/org/apache/iotdb/consensus/common/Utils.java
index 96d381949e..ddd17c6471 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/common/Utils.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/common/Utils.java
@@ -31,6 +31,7 @@ import java.nio.file.attribute.BasicFileAttributes;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.stream.Collectors;
 
 public class Utils {
   private static final Logger logger = LoggerFactory.getLogger(Utils.class);
@@ -74,4 +75,36 @@ public class Utils {
     }
     return allFiles;
   }
+
+  public static class MemorizedFileSizeCalc {
+    private List<Path> memorized;
+    private final File rootDir;
+    private long totalSize;
+
+    public MemorizedFileSizeCalc(File rootDir) {
+      this.memorized = Collections.emptyList();
+      this.rootDir = rootDir;
+      this.totalSize = 0;
+    }
+
+    public synchronized long getTotalFolderSize() {
+      final List<Path> latest = listAllRegularFilesRecursively(rootDir);
+
+      final List<Path> incremental =
+          latest.stream().filter(p -> !memorized.contains(p)).collect(Collectors.toList());
+
+      final List<Path> decremental =
+          memorized.stream().filter(p -> !latest.contains(p)).collect(Collectors.toList());
+
+      totalSize += incremental.stream().mapToLong(p -> p.toFile().length()).sum();
+      if (decremental.size() == memorized.size()) {
+        totalSize = 0;
+      } else {
+        totalSize -= decremental.stream().mapToLong(p -> p.toFile().length()).sum();
+      }
+
+      memorized = latest;
+      return totalSize;
+    }
+  }
 }
diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/config/RatisConfig.java b/consensus/src/main/java/org/apache/iotdb/consensus/config/RatisConfig.java
index 9677b82098..3a8dd16449 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/config/RatisConfig.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/config/RatisConfig.java
@@ -781,19 +781,26 @@ public class RatisConfig {
     private final long clientRetryInitialSleepTimeMs;
     private final long clientRetryMaxSleepTimeMs;
 
+    private final long triggerSnapshotTime;
+    private final long triggerSnapshotFileSize;
+
     private RatisConsensus(
         int retryTimesMax,
         long retryWaitMillis,
         long clientRequestTimeoutMillis,
         int clientMaxRetryAttempt,
         long clientRetryInitialSleepTimeMs,
-        long clientRetryMaxSleepTimeMs) {
+        long clientRetryMaxSleepTimeMs,
+        long triggerSnapshotTime,
+        long triggerSnapshotFileSize) {
       this.retryTimesMax = retryTimesMax;
       this.retryWaitMillis = retryWaitMillis;
       this.clientRequestTimeoutMillis = clientRequestTimeoutMillis;
       this.clientMaxRetryAttempt = clientMaxRetryAttempt;
       this.clientRetryInitialSleepTimeMs = clientRetryInitialSleepTimeMs;
       this.clientRetryMaxSleepTimeMs = clientRetryMaxSleepTimeMs;
+      this.triggerSnapshotTime = triggerSnapshotTime;
+      this.triggerSnapshotFileSize = triggerSnapshotFileSize;
     }
 
     public int getRetryTimesMax() {
@@ -820,6 +827,14 @@ public class RatisConfig {
       return clientRetryMaxSleepTimeMs;
     }
 
+    public long getTriggerSnapshotTime() {
+      return triggerSnapshotTime;
+    }
+
+    public long getTriggerSnapshotFileSize() {
+      return triggerSnapshotFileSize;
+    }
+
     public static RatisConsensus.Builder newBuilder() {
       return new Builder();
     }
@@ -833,6 +848,11 @@ public class RatisConfig {
       private long clientRetryInitialSleepTimeMs = 100;
       private long clientRetryMaxSleepTimeMs = 10000;
 
+      // 120s
+      private long triggerSnapshotTime = 120;
+      // 20GB
+      private long triggerSnapshotFileSize = 20L << 30;
+
       public RatisConsensus build() {
         return new RatisConsensus(
             retryTimesMax,
@@ -840,7 +860,9 @@ public class RatisConfig {
             clientRequestTimeoutMillis,
             clientMaxRetryAttempt,
             clientRetryInitialSleepTimeMs,
-            clientRetryMaxSleepTimeMs);
+            clientRetryMaxSleepTimeMs,
+            triggerSnapshotTime,
+            triggerSnapshotFileSize);
       }
 
       public RatisConsensus.Builder setRetryTimesMax(int retryTimesMax) {
@@ -873,6 +895,16 @@ public class RatisConfig {
         this.clientRetryMaxSleepTimeMs = clientRetryMaxSleepTimeMs;
         return this;
       }
+
+      public RatisConsensus.Builder setTriggerSnapshotTime(long triggerSnapshotTime) {
+        this.triggerSnapshotTime = triggerSnapshotTime;
+        return this;
+      }
+
+      public RatisConsensus.Builder setTriggerSnapshotFileSize(long triggerSnapshotFileSize) {
+        this.triggerSnapshotFileSize = triggerSnapshotFileSize;
+        return this;
+      }
     }
   }
 
diff --git a/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java b/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
index 7a7f3556a3..29c7ce9dd0 100644
--- a/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
+++ b/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
@@ -27,6 +27,7 @@ import org.apache.iotdb.commons.client.ClientPoolProperty;
 import org.apache.iotdb.commons.client.IClientManager;
 import org.apache.iotdb.commons.client.IClientPoolFactory;
 import org.apache.iotdb.commons.concurrent.IoTDBThreadPoolFactory;
+import org.apache.iotdb.commons.concurrent.threadpool.ScheduledExecutorUtil;
 import org.apache.iotdb.commons.conf.CommonDescriptor;
 import org.apache.iotdb.commons.consensus.ConsensusGroupId;
 import org.apache.iotdb.commons.utils.TestOnly;
@@ -34,6 +35,7 @@ import org.apache.iotdb.consensus.IConsensus;
 import org.apache.iotdb.consensus.IStateMachine;
 import org.apache.iotdb.consensus.common.DataSet;
 import org.apache.iotdb.consensus.common.Peer;
+import org.apache.iotdb.consensus.common.Utils.MemorizedFileSizeCalc;
 import org.apache.iotdb.consensus.common.request.IConsensusRequest;
 import org.apache.iotdb.consensus.common.response.ConsensusGenericResponse;
 import org.apache.iotdb.consensus.common.response.ConsensusReadResponse;
@@ -83,6 +85,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.stream.Collectors;
@@ -119,9 +122,12 @@ class RatisConsensus implements IConsensus {
   private static final int DEFAULT_WAIT_LEADER_READY_TIMEOUT = (int) TimeUnit.SECONDS.toMillis(20);
 
   private final ExecutorService addExecutor;
+  private final ScheduledExecutorService diskGuardian;
 
   private final RatisConfig config;
 
+  private final ConcurrentHashMap<File, MemorizedFileSizeCalc> calcMap = new ConcurrentHashMap<>();
+
   public RatisConsensus(ConsensusConfig config, IStateMachine.Registry registry)
       throws IOException {
     myself =
@@ -133,6 +139,8 @@ class RatisConsensus implements IConsensus {
     GrpcConfigKeys.Server.setPort(properties, config.getThisNodeEndPoint().getPort());
 
     addExecutor = IoTDBThreadPoolFactory.newCachedThreadPool("ratis-add");
+    diskGuardian =
+        IoTDBThreadPoolFactory.newSingleThreadScheduledExecutor("ratis-bg-disk-guardian");
 
     Utils.initRatisConfig(properties, config.getRatisConfig());
     this.config = config.getRatisConfig();
@@ -154,13 +162,16 @@ class RatisConsensus implements IConsensus {
   @Override
   public void start() throws IOException {
     server.start();
+    startSnapshotGuardian();
   }
 
   @Override
   public void stop() throws IOException {
     addExecutor.shutdown();
+    diskGuardian.shutdown();
     try {
       addExecutor.awaitTermination(5, TimeUnit.SECONDS);
+      diskGuardian.awaitTermination(5, TimeUnit.SECONDS);
     } catch (InterruptedException e) {
       logger.warn("{}: interrupted when shutting down add Executor with exception {}", this, e);
       Thread.currentThread().interrupt();
@@ -672,6 +683,43 @@ class RatisConsensus implements IConsensus {
     return ConsensusGenericResponse.newBuilder().setSuccess(reply.isSuccess()).build();
   }
 
+  private void triggerSnapshotByCustomize() {
+
+    Iterable<RaftGroupId> groupIds = server.getGroupIds();
+
+    for (RaftGroupId raftGroupId : groupIds) {
+      File currentDir = null;
+
+      try {
+        currentDir =
+            server.getDivision(raftGroupId).getRaftStorage().getStorageDir().getCurrentDir();
+      } catch (IOException e) {
+        logger.warn("Get division failed: ", e);
+        continue;
+      }
+
+      final long currentDirLength =
+          calcMap.computeIfAbsent(currentDir, MemorizedFileSizeCalc::new).getTotalFolderSize();
+      final long triggerSnapshotFileSize = config.getRatisConsensus().getTriggerSnapshotFileSize();
+
+      if (currentDirLength >= triggerSnapshotFileSize) {
+        ConsensusGenericResponse consensusGenericResponse =
+            triggerSnapshot(Utils.fromRaftGroupIdToConsensusGroupId(raftGroupId));
+        if (consensusGenericResponse.isSuccess()) {
+          logger.info("Raft group " + raftGroupId + " took snapshot successfully");
+        } else {
+          logger.warn("Raft group " + raftGroupId + " failed to take snapshot");
+        }
+      }
+    }
+  }
+
+  private void startSnapshotGuardian() {
+    final long delay = config.getRatisConsensus().getTriggerSnapshotTime();
+    ScheduledExecutorUtil.safelyScheduleWithFixedDelay(
+        diskGuardian, this::triggerSnapshotByCustomize, 0, delay, TimeUnit.SECONDS);
+  }
+
   private ConsensusGenericResponse failed(ConsensusException e) {
     logger.debug("{} request failed with exception {}", this, e);
     return ConsensusGenericResponse.newBuilder().setSuccess(false).setException(e).build();
diff --git a/consensus/src/test/java/org/apache/iotdb/consensus/ratis/RatisConsensusTest.java b/consensus/src/test/java/org/apache/iotdb/consensus/ratis/RatisConsensusTest.java
index fd65d1ee71..8e790020cd 100644
--- a/consensus/src/test/java/org/apache/iotdb/consensus/ratis/RatisConsensusTest.java
+++ b/consensus/src/test/java/org/apache/iotdb/consensus/ratis/RatisConsensusTest.java
@@ -70,7 +70,16 @@ public class RatisConsensusTest {
                       .setPurgeGap(10)
                       .setUnsafeFlushEnabled(false)
                       .build())
-              .setSnapshot(RatisConfig.Snapshot.newBuilder().setAutoTriggerThreshold(100).build())
+              .setSnapshot(
+                  RatisConfig.Snapshot.newBuilder()
+                      .setAutoTriggerThreshold(100)
+                      .setCreationGap(10)
+                      .build())
+              .setRatisConsensus(
+                  RatisConfig.RatisConsensus.newBuilder()
+                      .setTriggerSnapshotFileSize(1)
+                      .setTriggerSnapshotTime(4)
+                      .build())
               .build();
       int finalI = i;
       servers.add(
diff --git a/node-commons/src/assembly/resources/conf/iotdb-common.properties b/node-commons/src/assembly/resources/conf/iotdb-common.properties
index 7a98179ecd..393067567e 100644
--- a/node-commons/src/assembly/resources/conf/iotdb-common.properties
+++ b/node-commons/src/assembly/resources/conf/iotdb-common.properties
@@ -964,6 +964,11 @@
 # schema_region_ratis_preserve_logs_num_when_purge=1000
 # data_region_ratis_preserve_logs_num_when_purge=1000
 
+# Raft Log disk size control
+# config_node_ratis_log_max_size = 2147483648
+# schema_region_ratis_log_max_size = 2147483648
+# data_region_ratis_log_max_size = 21474836480
+
 ####################
 ### Procedure Configuration
 ####################
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index a55c11bec9..6a1f46f760 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -1035,6 +1035,9 @@ public class IoTDBConfig {
   private long ratisFirstElectionTimeoutMinMs = 50L;
   private long ratisFirstElectionTimeoutMaxMs = 150L;
 
+  private long dataRatisLogMaxMB = 20 * 1024;
+  private long schemaRatisLogMaxMB = 2 * 1024;
+
   // customizedProperties, this should be empty by default.
   private Properties customizedProperties = new Properties();
 
@@ -3558,4 +3561,20 @@ public class IoTDBConfig {
   public void setRatisFirstElectionTimeoutMaxMs(long ratisFirstElectionTimeoutMaxMs) {
     this.ratisFirstElectionTimeoutMaxMs = ratisFirstElectionTimeoutMaxMs;
   }
+
+  public long getDataRatisLogMaxMB() {
+    return dataRatisLogMaxMB;
+  }
+
+  public void setDataRatisLogMaxMB(long dataRatisLogMaxMB) {
+    this.dataRatisLogMaxMB = dataRatisLogMaxMB;
+  }
+
+  public long getSchemaRatisLogMaxMB() {
+    return schemaRatisLogMaxMB;
+  }
+
+  public void setSchemaRatisLogMaxMB(long schemaRatisLogMaxMB) {
+    this.schemaRatisLogMaxMB = schemaRatisLogMaxMB;
+  }
 }
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index dd3bb85a91..5373b4d7b0 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -1975,6 +1975,9 @@ public class IoTDBDescriptor {
 
     conf.setRatisFirstElectionTimeoutMinMs(ratisConfig.getFirstElectionTimeoutMin());
     conf.setRatisFirstElectionTimeoutMaxMs(ratisConfig.getFirstElectionTimeoutMax());
+
+    conf.setSchemaRatisLogMaxMB(ratisConfig.getSchemaRegionRatisLogMax());
+    conf.setDataRatisLogMaxMB(ratisConfig.getDataRegionRatisLogMax());
   }
 
   public void loadCQConfig(TCQConfig cqConfig) {
diff --git a/server/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java b/server/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java
index b87e2cb968..af866ae6fc 100644
--- a/server/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/consensus/DataRegionConsensusImpl.java
@@ -157,6 +157,8 @@ public class DataRegionConsensusImpl {
                                           conf.getDataRatisConsensusInitialSleepTimeMs())
                                       .setClientRetryMaxSleepTimeMs(
                                           conf.getDataRatisConsensusMaxSleepTimeMs())
+                                      .setTriggerSnapshotFileSize(
+                                          conf.getDataRatisLogMaxMB() * 1024 * 1024)
                                       .build())
                               .build())
                       .build(),
diff --git a/server/src/main/java/org/apache/iotdb/db/consensus/SchemaRegionConsensusImpl.java b/server/src/main/java/org/apache/iotdb/db/consensus/SchemaRegionConsensusImpl.java
index 59e9b066d3..e605084bd5 100644
--- a/server/src/main/java/org/apache/iotdb/db/consensus/SchemaRegionConsensusImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/consensus/SchemaRegionConsensusImpl.java
@@ -125,6 +125,8 @@ public class SchemaRegionConsensusImpl {
                                           conf.getSchemaRatisConsensusInitialSleepTimeMs())
                                       .setClientRetryMaxSleepTimeMs(
                                           conf.getSchemaRatisConsensusMaxSleepTimeMs())
+                                      .setTriggerSnapshotFileSize(
+                                          conf.getSchemaRatisLogMaxMB() * 1024 * 1024)
                                       .build())
                               .build())
                       .setStorageDir(conf.getSchemaRegionConsensusDir())
diff --git a/thrift-confignode/src/main/thrift/confignode.thrift b/thrift-confignode/src/main/thrift/confignode.thrift
index 3a51d98e2b..a9ab4c31c9 100644
--- a/thrift-confignode/src/main/thrift/confignode.thrift
+++ b/thrift-confignode/src/main/thrift/confignode.thrift
@@ -89,6 +89,9 @@ struct TRatisConfig {
 
   25: required i64 firstElectionTimeoutMin
   26: required i64 firstElectionTimeoutMax
+
+  27: required i64 schemaRegionRatisLogMax
+  28: required i64 dataRegionRatisLogMax
 }
 
 struct TCQConfig {