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 2020/07/23 05:45:45 UTC

[incubator-iotdb] branch master updated: [IOTDB-811] fix upgrading mlog many times when upgrading system.properties crashed (#1543)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 75ad80c  [IOTDB-811] fix upgrading mlog many times when upgrading system.properties crashed (#1543)
75ad80c is described below

commit 75ad80cf8e8e698e2f4772d213e16dc6496ae7cc
Author: Haonan <hh...@outlook.com>
AuthorDate: Thu Jul 23 13:45:34 2020 +0800

    [IOTDB-811] fix upgrading mlog many times when upgrading system.properties crashed (#1543)
    
    * fix upgrading mlog many times
    Co-authored-by: Jialin Qiao <qj...@mails.tsinghua.edu.cn>
    Co-authored-by: Zesong Sun <sz...@mails.tsinghua.edu.cn>
---
 .../java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java     | 13 ++++++++++++-
 .../main/java/org/apache/iotdb/db/metadata/MLogWriter.java  |  8 --------
 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 e97a52d..5c8d6e0 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
@@ -191,6 +191,18 @@ 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
+      FileUtils.moveFile(tmpMLogFile, mlogFile);
     }
     checkProperties();
   }
@@ -333,4 +345,3 @@ public class IoTDBConfigCheck {
 
 }
 
-
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 6b41a44..c00206e 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
@@ -152,14 +152,6 @@ public class MLogWriter {
         writer.flush();
       }
     }
-
-    // upgrade finished, delete old mlog file
-    if (!logFile.delete()) {
-      throw new IOException("Deleting " + logFile + "failed.");
-    }
-
-    // rename tmpLogFile to mlog
-    FSFactoryProducer.getFSFactory().moveFile(tmpLogFile, logFile);
   }
 
   public void clear() throws IOException {