You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ma...@apache.org on 2022/08/29 03:07:00 UTC

[iotdb] branch IOTDB-4211 created (now 679f725236)

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

marklau99 pushed a change to branch IOTDB-4211
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 679f725236 add param enable_snapshot

This branch includes the following new commits:

     new 679f725236 add param enable_snapshot

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: add param enable_snapshot

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

marklau99 pushed a commit to branch IOTDB-4211
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 679f7252366aa09274df6464e864665bf27cc112
Author: Liu Xuxin <li...@outlook.com>
AuthorDate: Mon Aug 29 11:06:32 2022 +0800

    add param enable_snapshot
---
 .../resources/conf/iotdb-datanode.properties       |  9 ++++++++-
 .../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 10 ++++++++++
 .../org/apache/iotdb/db/conf/IoTDBDescriptor.java  |  4 ++++
 .../statemachine/DataRegionStateMachine.java       | 22 +++++++++++++---------
 4 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/server/src/assembly/resources/conf/iotdb-datanode.properties b/server/src/assembly/resources/conf/iotdb-datanode.properties
index def08b4787..d941beda4b 100644
--- a/server/src/assembly/resources/conf/iotdb-datanode.properties
+++ b/server/src/assembly/resources/conf/iotdb-datanode.properties
@@ -1119,4 +1119,11 @@ trigger_forward_mqtt_pool_size=4
 # external_limiter_dir=ext\\limiter
 # For Linux platform
 # If its prefix is "/", then the path is absolute. Otherwise, it is relative.
-# external_limiter_dir=ext/limiter
\ No newline at end of file
+# external_limiter_dir=ext/limiter
+
+####################
+### Snapshot Configuration
+####################
+
+# enable taking snapshot in distributed mode
+# enable_snapshot=true
\ No newline at end of file
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 fda9580ef5..e6a857b017 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
@@ -979,8 +979,18 @@ public class IoTDBConfig {
   /** Maximum size of wal buffer used in MultiLeader consensus. Unit: byte */
   private long throttleThreshold = 50 * 1024 * 1024 * 1024L;
 
+  private boolean enableSnapshot = true;
+
   IoTDBConfig() {}
 
+  public boolean isEnableSnapshot() {
+    return enableSnapshot;
+  }
+
+  public void setEnableSnapshot(boolean enableSnapshot) {
+    this.enableSnapshot = enableSnapshot;
+  }
+
   public float getUdfMemoryBudgetInMB() {
     return udfMemoryBudgetInMB;
   }
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 182c126c56..b90b261ed5 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
@@ -345,6 +345,10 @@ public class IoTDBDescriptor {
                 "enable_mem_control", Boolean.toString(conf.isEnableMemControl())))));
     logger.info("IoTDB enable memory control: {}", conf.isEnableMemControl());
 
+    conf.setEnableSnapshot(
+        (Boolean.parseBoolean(
+            properties.getProperty("enable_snapshot", Boolean.toString(conf.isEnableSnapshot())))));
+
     long seqTsFileSize =
         Long.parseLong(
             properties
diff --git a/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/DataRegionStateMachine.java b/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/DataRegionStateMachine.java
index d5cf5e4533..0ba8e344f6 100644
--- a/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/DataRegionStateMachine.java
+++ b/server/src/main/java/org/apache/iotdb/db/consensus/statemachine/DataRegionStateMachine.java
@@ -95,15 +95,19 @@ public class DataRegionStateMachine extends BaseStateMachine {
 
   @Override
   public boolean takeSnapshot(File snapshotDir) {
-    try {
-      return new SnapshotTaker(region).takeFullSnapshot(snapshotDir.getAbsolutePath(), true);
-    } catch (Exception e) {
-      logger.error(
-          "Exception occurs when taking snapshot for {}-{} in {}",
-          region.getStorageGroupName(),
-          region.getDataRegionId(),
-          snapshotDir,
-          e);
+    if (IoTDBDescriptor.getInstance().getConfig().isEnableSnapshot()) {
+      try {
+        return new SnapshotTaker(region).takeFullSnapshot(snapshotDir.getAbsolutePath(), true);
+      } catch (Exception e) {
+        logger.error(
+            "Exception occurs when taking snapshot for {}-{} in {}",
+            region.getStorageGroupName(),
+            region.getDataRegionId(),
+            snapshotDir,
+            e);
+        return false;
+      }
+    } else {
       return false;
     }
   }