This is an automated email from the ASF dual-hosted git repository.
sunzesong pushed a commit to branch MLogBug
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/MLogBug by this push:
new 0dc4c13 Add switch for MTree snapshot
0dc4c13 is described below
commit 0dc4c13857e06909a4c002adafcbbbf5bba66d9c
Author: samperson1997 <[email protected]>
AuthorDate: Mon Oct 26 17:23:37 2020 +0800
Add switch for MTree snapshot
---
.../assembly/resources/conf/iotdb-engine.properties | 7 ++++++-
.../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 13 +++++++++++++
.../org/apache/iotdb/db/conf/IoTDBDescriptor.java | 2 ++
.../java/org/apache/iotdb/db/metadata/MManager.java | 20 +++++++++++---------
4 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/server/src/assembly/resources/conf/iotdb-engine.properties
b/server/src/assembly/resources/conf/iotdb-engine.properties
index 3045cce..183ba86 100644
--- a/server/src/assembly/resources/conf/iotdb-engine.properties
+++ b/server/src/assembly/resources/conf/iotdb-engine.properties
@@ -207,11 +207,16 @@ tag_attribute_total_size=700
# if enable partial insert, one measurement failure will not impact other
measurements
enable_partial_insert=true
-# The least interval line numbers of mlog.txt when creating a checkpoint and
saving snapshot of MTree. Unit: line numbers
+# Whether to enable MTree snapshot. Default false in 0.11.0
+enable_mtree_snapshot=false
+
+# The least interval line numbers of mlog.txt when creating a checkpoint and
saving snapshot of MTree.
+# Only take effect when enable_mtree_snapshot=true. Unit: line numbers
mtree_snapshot_interval=100000
# Threshold interval time of MTree modification. Unit: second. Default: 1
hour(3600 seconds)
# If the last modification time is less than this threshold, MTree snapshot
will not be created
+# Only take effect when enable_mtree_snapshot=true.
mtree_snapshot_threshold_time=3600
####################
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 89f053b..f873ca5 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
@@ -661,6 +661,11 @@ public class IoTDBConfig {
private boolean enablePartition = false;
/**
+ * whether enable MTree snapshot
+ */
+ private boolean enableMTreeSnapshot = false;
+
+ /**
* Interval line number of mlog.txt when creating a checkpoint and saving
snapshot of mtree
*/
private int mtreeSnapshotInterval = 100000;
@@ -726,6 +731,14 @@ public class IoTDBConfig {
this.enablePartition = enablePartition;
}
+ public boolean isEnableMTreeSnapshot() {
+ return enableMTreeSnapshot;
+ }
+
+ public void setEnableMTreeSnapshot(boolean enableMTreeSnapshot) {
+ this.enableMTreeSnapshot = enableMTreeSnapshot;
+ }
+
public int getMtreeSnapshotInterval() {
return mtreeSnapshotInterval;
}
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 4fe9ecb..7f9e9b3 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
@@ -381,6 +381,8 @@ public class IoTDBDescriptor {
Boolean.parseBoolean(properties.getProperty("enable_partial_insert",
String.valueOf(conf.isEnablePartialInsert()))));
+ conf.setEnableMTreeSnapshot(Boolean.parseBoolean(properties.getProperty(
+ "enable_mtree_snapshot",
Boolean.toString(conf.isEnableMTreeSnapshot()))));
conf.setMtreeSnapshotInterval(Integer.parseInt(properties.getProperty(
"mtree_snapshot_interval",
Integer.toString(conf.getMtreeSnapshotInterval()))));
conf.setMtreeSnapshotThresholdTime(Integer.parseInt(properties.getProperty(
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
index f4c6c3f..6886259 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
@@ -94,12 +94,12 @@ public class MManager {
public static final String TIME_SERIES_TREE_HEADER = "=== Timeseries Tree
===\n\n";
private static final String TAG_FORMAT = "tag key is %s, tag value is %s,
tlog offset is %d";
- private static final String DEBUG_MSG = "%s : TimeSeries %s is removed from
tag inverted index, ";
+ private static final String DEBUG_MSG = "%s : TimeSeries %s is removed from
tag inverted index, ";
private static final String DEBUG_MSG_1 = "%s: TimeSeries %s's tag info has
been removed from tag inverted index ";
private static final String PREVIOUS_CONDITION = "before deleting it, tag
key is %s, tag value is %s, tlog offset is %d, contains key %b";
-
+
private static final Logger logger = LoggerFactory.getLogger(MManager.class);
-
+
/**
* A thread will check whether the MTree is modified lately each such
interval. Unit: second
*/
@@ -159,11 +159,13 @@ public class MManager {
}
};
- timedCreateMTreeSnapshotThread =
Executors.newSingleThreadScheduledExecutor(r -> new Thread(r,
- "timedCreateMTreeSnapshotThread"));
- timedCreateMTreeSnapshotThread
- .scheduleAtFixedRate(this::checkMTreeModified,
MTREE_SNAPSHOT_THREAD_CHECK_TIME,
- MTREE_SNAPSHOT_THREAD_CHECK_TIME, TimeUnit.SECONDS);
+ if (config.isEnableMTreeSnapshot()) {
+ timedCreateMTreeSnapshotThread =
Executors.newSingleThreadScheduledExecutor(r -> new Thread(r,
+ "timedCreateMTreeSnapshotThread"));
+ timedCreateMTreeSnapshotThread
+ .scheduleAtFixedRate(this::checkMTreeModified,
MTREE_SNAPSHOT_THREAD_CHECK_TIME,
+ MTREE_SNAPSHOT_THREAD_CHECK_TIME, TimeUnit.SECONDS);
+ }
}
/**
@@ -273,7 +275,7 @@ public class MManager {
tagLogFile = null;
}
initialized = false;
- if (timedCreateMTreeSnapshotThread != null) {
+ if (config.isEnableMTreeSnapshot() && timedCreateMTreeSnapshotThread !=
null) {
timedCreateMTreeSnapshotThread.shutdownNow();
timedCreateMTreeSnapshotThread = null;
}