You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2021/05/13 06:07:00 UTC

[iotdb] branch rel/0.12 updated: [To rel/0.12] Fix upgrade tool cannot load old tsfile if time partition enabled in 0.11 (#3154)

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

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


The following commit(s) were added to refs/heads/rel/0.12 by this push:
     new 676b1f1  [To rel/0.12] Fix upgrade tool cannot load old tsfile if time partition enabled in 0.11 (#3154)
676b1f1 is described below

commit 676b1f1e879655db8b6cdbea7c9f07cdaf362089
Author: Haonan <hh...@outlook.com>
AuthorDate: Thu May 13 14:06:40 2021 +0800

    [To rel/0.12] Fix upgrade tool cannot load old tsfile if time partition enabled in 0.11 (#3154)
---
 .../org/apache/iotdb/db/conf/IoTDBConfigCheck.java | 28 +++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
index d7ce4e5..53b418c 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
@@ -241,6 +241,14 @@ public class IoTDBConfigCheck {
       System.exit(-1);
     }
 
+    // virtual storage group num can only set to 1 when upgrading from old version
+    if (!virtualStorageGroupNum.equals("1")) {
+      logger.error(
+          "virtual storage group num cannot set to {} when upgrading from old version, "
+              + "please set to 1 and restart",
+          virtualStorageGroupNum);
+      System.exit(-1);
+    }
     try (FileOutputStream tmpFOS = new FileOutputStream(tmpPropertiesFile.toString())) {
       properties.setProperty(PARTITION_INTERVAL_STRING, String.valueOf(partitionInterval));
       properties.setProperty(TSFILE_FILE_SYSTEM_STRING, tsfileFileSystem);
@@ -428,6 +436,16 @@ public class IoTDBConfigCheck {
         if (!storageGroup.isDirectory()) {
           continue;
         }
+        // create virtual storage group folder 0
+        File virtualStorageGroupDir = fsFactory.getFile(storageGroup, "0");
+        if (virtualStorageGroupDir.mkdirs()) {
+          logger.info(
+              "virtual storage directory {} doesn't exist, create it",
+              virtualStorageGroupDir.getPath());
+        } else if (!virtualStorageGroupDir.exists()) {
+          logger.error(
+              "Create virtual storage directory {} failed", virtualStorageGroupDir.getPath());
+        }
         for (File partitionDir : storageGroup.listFiles()) {
           if (!partitionDir.isDirectory()) {
             continue;
@@ -446,7 +464,8 @@ public class IoTDBConfigCheck {
           if (oldTsfileArray.length + oldResourceFileArray.length + oldModificationFileArray.length
               != 0) {
             // create upgrade directory if not exist
-            File upgradeFolder = fsFactory.getFile(partitionDir, IoTDBConstant.UPGRADE_FOLDER_NAME);
+            File upgradeFolder =
+                fsFactory.getFile(virtualStorageGroupDir, IoTDBConstant.UPGRADE_FOLDER_NAME);
             if (upgradeFolder.mkdirs()) {
               logger.info("Upgrade Directory {} doesn't exist, create it", upgradeFolder.getPath());
             } else if (!upgradeFolder.exists()) {
@@ -471,6 +490,13 @@ public class IoTDBConfigCheck {
               }
             }
           }
+          if (partitionDir.listFiles().length == 0) {
+            try {
+              Files.delete(partitionDir.toPath());
+            } catch (IOException e) {
+              logger.error("Delete {} failed", partitionDir);
+            }
+          }
         }
       }
     }