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

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

commit 2a4817eb4e4c29c4a10f0246154ab002df7d35c0
Author: Marccos <[email protected]>
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();

Reply via email to