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/12/16 05:13:56 UTC
[iotdb] branch master updated: fix file not found when restart and
reader for txt mlog (#2272)
This is an automated email from the ASF dual-hosted git repository.
haonan 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 12abbe9 fix file not found when restart and reader for txt mlog (#2272)
12abbe9 is described below
commit 12abbe98a052f3ffe8a27d855278eb697bb6ee66
Author: chaow <ru...@foxmail.com>
AuthorDate: Wed Dec 16 13:13:40 2020 +0800
fix file not found when restart and reader for txt mlog (#2272)
---
.../org/apache/iotdb/db/metadata/logfile/MLogTxtReader.java | 4 +++-
.../java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java | 10 +++++++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogTxtReader.java b/server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogTxtReader.java
index 022d3be..6285a6b 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogTxtReader.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogTxtReader.java
@@ -50,7 +50,9 @@ public class MLogTxtReader implements AutoCloseable {
}
public String next() {
- return cmd;
+ String ret = cmd;
+ cmd = null;
+ return ret;
}
public boolean hasNext() {
diff --git a/server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java b/server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
index 9fea132..9628c62 100644
--- a/server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
+++ b/server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
@@ -246,12 +246,19 @@ public class MLogWriter implements AutoCloseable {
// upgrade from old character log file to new binary mlog
while (mLogTxtReader.hasNext()) {
String cmd = mLogTxtReader.next();
+ if (cmd == null) {
+ // no more cmd
+ break;
+ }
try {
mLogWriter.operation(cmd, isSnapshot);
} catch (MetadataException e) {
logger.error("failed to upgrade cmd {}.", cmd, e);
}
}
+
+ // rename .bin.tmp to .bin
+ FSFactoryProducer.getFSFactory().moveFile(tmpLogFile, logFile);
}
} else if (!logFile.exists() && !tmpLogFile.exists()) {
// if both .bin and .bin.tmp do not exist, nothing to do
@@ -284,9 +291,6 @@ public class MLogWriter implements AutoCloseable {
throw new IOException(String.format(DELETE_FAILED_FORMAT, tmpOldLogFile, e.getMessage()));
}
}
-
- // rename .bin.tmp to .bin
- FSFactoryProducer.getFSFactory().moveFile(tmpLogFile, logFile);
}
public static void upgradeMLog() throws IOException {