You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2021/01/21 06:40:37 UTC

[iotdb] branch upgrade_recover_bug created (now ff9cb42)

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

haonan pushed a change to branch upgrade_recover_bug
in repository https://gitbox.apache.org/repos/asf/iotdb.git.


      at ff9cb42  fix some upgrade recover bugs

This branch includes the following new commits:

     new ff9cb42  fix some upgrade recover bugs

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: fix some upgrade recover bugs

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

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

commit ff9cb42521397c593407b57e55f543ba814e0107
Author: HTHou <hh...@outlook.com>
AuthorDate: Thu Jan 21 14:40:03 2021 +0800

    fix some upgrade recover bugs
---
 .../apache/iotdb/db/engine/upgrade/UpgradeTask.java    |  3 ++-
 .../java/org/apache/iotdb/db/utils/UpgradeUtils.java   | 18 +++++++++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/engine/upgrade/UpgradeTask.java b/server/src/main/java/org/apache/iotdb/db/engine/upgrade/UpgradeTask.java
index deb8e27..3a977df 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/upgrade/UpgradeTask.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/upgrade/UpgradeTask.java
@@ -100,7 +100,8 @@ public class UpgradeTask extends WrappedRunnable {
       File upgradeFolder = upgradeResource.getTsFile().getParentFile();
       for (File tempPartitionDir : upgradeFolder.listFiles()) {
         if (tempPartitionDir.isDirectory() && 
-            fsFactory.getFile(tempPartitionDir, upgradeResource.getTsFile().getName()).exists()) {
+            fsFactory.getFile(tempPartitionDir, upgradeResource.getTsFile().getName() 
+                + TsFileResource.RESOURCE_SUFFIX).exists()) {
           TsFileResource resource = new TsFileResource(
               fsFactory.getFile(tempPartitionDir, upgradeResource.getTsFile().getName()));
           resource.deserialize();
diff --git a/server/src/main/java/org/apache/iotdb/db/utils/UpgradeUtils.java b/server/src/main/java/org/apache/iotdb/db/utils/UpgradeUtils.java
index e16a118..da9bddd 100644
--- a/server/src/main/java/org/apache/iotdb/db/utils/UpgradeUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/utils/UpgradeUtils.java
@@ -101,11 +101,13 @@ public class UpgradeUtils {
         partitionDir.mkdir();
       }
       // move upgraded TsFile
-      fsFactory.moveFile(upgradedFile,
+      if (upgradedFile.exists()) {
+        fsFactory.moveFile(upgradedFile,
           fsFactory.getFile(partitionDir, upgradedFile.getName()));
-      // delete generated temp resource
-      Files.delete(fsFactory
-          .getFile(upgradedResource.getTsFile().toPath() + TsFileResource.RESOURCE_SUFFIX).toPath());
+      }
+      // get temp resource
+      File tempResourceFile = fsFactory
+          .getFile(upgradedResource.getTsFile().toPath() + TsFileResource.RESOURCE_SUFFIX);
       // move upgraded mods file
       File newModsFile = fsFactory
           .getFile(upgradedResource.getTsFile().toPath() + ModificationFile.FILE_SUFFIX);
@@ -116,10 +118,13 @@ public class UpgradeUtils {
       // re-serialize upgraded resource to correct place
       upgradedResource.setFile(
           fsFactory.getFile(partitionDir, upgradedFile.getName()));
-      if (newModsFile.exists()) {
+      if (fsFactory.getFile(partitionDir, newModsFile.getName()).exists()) {
         upgradedResource.getModFile();
       }
+      upgradedResource.setClosed(true);
       upgradedResource.serialize();
+      // delete generated temp resource file
+      Files.delete(tempResourceFile.toPath());
       // delete tmp partition folder when it is empty
       File tmpPartitionDir = upgradedFile.getParentFile();
       if (tmpPartitionDir.isDirectory() && tmpPartitionDir.listFiles().length == 0) {
@@ -161,6 +166,9 @@ public class UpgradeUtils {
             File upgradeDir = FSFactoryProducer.getFSFactory().getFile(key)
                 .getParentFile();
             File[] partitionDirs = upgradeDir.listFiles();
+            if (partitionDirs == null) {
+              return;
+            }
             for (File partitionDir : partitionDirs) {
               if (partitionDir.isDirectory()) {
                 File[] generatedFiles = partitionDir.listFiles();