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 12:19:37 UTC

[iotdb] branch master updated: [IOTDB-5061] Add initialize state check when create snapshot (#8447)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 4a32eb8a77 [IOTDB-5061] Add initialize state check when create snapshot (#8447)
4a32eb8a77 is described below

commit 4a32eb8a77209f58b5c8246847c4ac98e8babb05
Author: Marcos_Zyk <38...@users.noreply.github.com>
AuthorDate: Wed Dec 14 20:19:30 2022 +0800

    [IOTDB-5061] Add initialize state check when create snapshot (#8447)
    
    [IOTDB-5061] Add initialize state check when create snapshot (#8447)
---
 .../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..1665a2854a 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 the 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..1ddca04302 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 the schemaRegion has not been initialized.",
+          schemaRegionId);
+      return false;
+    }
     logger.info("Start create snapshot of schemaRegion {}", schemaRegionId);
     boolean isSuccess = true;
     long startTime = System.currentTimeMillis();