You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by zy...@apache.org on 2022/12/14 03:35:10 UTC

[iotdb] branch 1.0_snapshot_check created (now 8e64f28d78)

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

zyk pushed a change to branch 1.0_snapshot_check
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at 8e64f28d78 add initialize state check when create snapshot

This branch includes the following new commits:

     new 8e64f28d78 add initialize state check when create 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 initialize state check when create snapshot

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

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

commit 8e64f28d788e0f4a7ef8d3136508f691475692ae
Author: Marccos <15...@qq.com>
AuthorDate: Wed Dec 14 11:35:02 2022 +0800

    add initialize state check when create snapshot
---
 .../iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java      | 6 ++++++
 .../iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java  | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
index 0cf41e3fd8..fa3db2d191 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java
@@ -437,6 +437,12 @@ public class SchemaRegionMemoryImpl implements ISchemaRegion {
   // currently, this method is only used for cluster-ratis mode
   @Override
   public synchronized boolean createSnapshot(File snapshotDir) {
+    if (!initialized) {
+      logger.warn(
+          "Failed to create snapshot of schemaRegion {}, because thi schemaRegion has not been initialized.",
+          schemaRegionId);
+      return false;
+    }
     logger.info("Start create snapshot of schemaRegion {}", schemaRegionId);
     boolean isSuccess = true;
     long startTime = System.currentTimeMillis();
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
index 1146b04f07..a8528c72d2 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionSchemaFileImpl.java
@@ -424,6 +424,12 @@ public class SchemaRegionSchemaFileImpl implements ISchemaRegion {
 
   @Override
   public boolean createSnapshot(File snapshotDir) {
+    if (!initialized) {
+      logger.warn(
+          "Failed to create snapshot of schemaRegion {}, because thi schemaRegion has not been initialized.",
+          schemaRegionId);
+      return false;
+    }
     logger.info("Start create snapshot of schemaRegion {}", schemaRegionId);
     boolean isSuccess = true;
     long startTime = System.currentTimeMillis();