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 2020/07/22 13:45:24 UTC

[incubator-iotdb] 01/01: fix updating mlog many times

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

haonan pushed a commit to branch fix_upgrade_0.10
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 6a31c43050a4901adc62c53ab208715094395e64
Author: HTHou <hh...@outlook.com>
AuthorDate: Wed Jul 22 21:44:43 2020 +0800

    fix updating mlog many times
---
 .../main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java  | 11 +++++++++++
 .../main/java/org/apache/iotdb/db/metadata/MLogWriter.java    | 10 +---------
 2 files changed, 12 insertions(+), 9 deletions(-)

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 d7c3a63..1c8b49c 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
@@ -187,6 +187,17 @@ public class IoTDBConfigCheck {
       checkUnClosedTsFileV1();
       MLogWriter.upgradeMLog(SCHEMA_DIR, MetadataConstant.METADATA_LOG);
       upgradePropertiesFile();
+      // upgrade mlog finished, delete old mlog file
+      File mlogFile = SystemFileFactory.INSTANCE.getFile(SCHEMA_DIR + File.separator
+          + MetadataConstant.METADATA_LOG);
+      File tmpMLogFile = SystemFileFactory.INSTANCE.getFile(mlogFile.getAbsolutePath()
+          + ".tmp");
+      
+      if (!mlogFile.delete()) {
+        throw new IOException("Deleting " + mlogFile + "failed.");
+      }
+      // rename tmpLogFile to mlog
+      FSFactoryProducer.getFSFactory().moveFile(tmpMLogFile, mlogFile);
     }
     checkProperties();
   }
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/MLogWriter.java b/server/src/main/java/org/apache/iotdb/db/metadata/MLogWriter.java
index 72ee54b..63948f3 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/MLogWriter.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/MLogWriter.java
@@ -161,14 +161,6 @@ public class MLogWriter {
         
       }
     }
-
-    // upgrade finished, delete old mlog file
-    if (!logFile.delete()) {
-      throw new IOException("Deleting " + logFile + "failed.");
-    }
-    
-    // rename tmpLogFile to mlog
-    FSFactoryProducer.getFSFactory().moveFile(tmpLogFile, logFile);
   }
-  
+
 }