You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ma...@apache.org on 2022/07/04 09:57:34 UTC
[iotdb] branch IOTDB-3738 updated: make MergeLogAnalyzer compatible with old version log that contains merge progress
This is an automated email from the ASF dual-hosted git repository.
marklau99 pushed a commit to branch IOTDB-3738
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/IOTDB-3738 by this push:
new c2b223c889 make MergeLogAnalyzer compatible with old version log that contains merge progress
c2b223c889 is described below
commit c2b223c889ed133e40fb33961746dacbd95899a9
Author: Liu Xuxin <li...@outlook.com>
AuthorDate: Mon Jul 4 17:57:27 2022 +0800
make MergeLogAnalyzer compatible with old version log that contains merge progress
---
.../db/engine/merge/recover/MergeFileInfo.java | 8 ++++++-
.../db/engine/merge/recover/MergeLogAnalyzer.java | 23 ++++++++++++++++----
.../exception/compaction/CompactionException.java | 25 ++++++++++++++++++++++
.../compaction/InvalidCompactionLogException.java | 25 ++++++++++++++++++++++
4 files changed, 76 insertions(+), 5 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/merge/recover/MergeFileInfo.java b/server/src/main/java/org/apache/iotdb/db/engine/merge/recover/MergeFileInfo.java
index 2e6863abb7..e6952ba7a4 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/merge/recover/MergeFileInfo.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/merge/recover/MergeFileInfo.java
@@ -19,6 +19,7 @@
package org.apache.iotdb.db.engine.merge.recover;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.exception.compaction.InvalidCompactionLogException;
import java.io.File;
@@ -60,10 +61,15 @@ public class MergeFileInfo {
paths[pathLength - 5].equals("sequence"));
}
- public static MergeFileInfo getFileInfoFromString(String infoString) {
+ public static MergeFileInfo getFileInfoFromString(String infoString)
+ throws InvalidCompactionLogException {
if (!infoString.contains(File.separator)) {
// the info string records info of merge files
String[] splits = infoString.split(" ");
+ if (splits.length != 5) {
+ throw new InvalidCompactionLogException("Invalid file info string " + infoString);
+ }
+
return new MergeFileInfo(
splits[0],
splits[1],
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/merge/recover/MergeLogAnalyzer.java b/server/src/main/java/org/apache/iotdb/db/engine/merge/recover/MergeLogAnalyzer.java
index 4b13c3fd34..a5b241531e 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/merge/recover/MergeLogAnalyzer.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/merge/recover/MergeLogAnalyzer.java
@@ -21,6 +21,7 @@ package org.apache.iotdb.db.engine.merge.recover;
import org.apache.iotdb.db.engine.merge.manage.MergeResource;
import org.apache.iotdb.db.engine.storagegroup.TsFileResource;
+import org.apache.iotdb.db.exception.compaction.InvalidCompactionLogException;
import org.apache.iotdb.db.exception.metadata.MetadataException;
import org.slf4j.Logger;
@@ -95,7 +96,14 @@ public class MergeLogAnalyzer {
break;
}
Iterator<TsFileResource> iterator = resource.getSeqFiles().iterator();
- MergeFileInfo toMatchedInfo = MergeFileInfo.getFileInfoFromString(currLine);
+ MergeFileInfo toMatchedInfo = null;
+ try {
+ toMatchedInfo = MergeFileInfo.getFileInfoFromString(currLine);
+ } catch (InvalidCompactionLogException e) {
+ // this line is invalid, skip it
+ logger.warn("Invalid file info line {}", currLine);
+ continue;
+ }
boolean currentFileFound = false;
while (iterator.hasNext()) {
TsFileResource seqFile = iterator.next();
@@ -114,7 +122,7 @@ public class MergeLogAnalyzer {
new TsFileResource(
new File(
resource.getSeqFiles().get(0).getTsFile().getParent(),
- MergeFileInfo.getFileInfoFromString(currLine).filename)));
+ toMatchedInfo.filename)));
allSourceFileExists = false;
}
}
@@ -140,7 +148,14 @@ public class MergeLogAnalyzer {
boolean allSourceFileExists = true;
while ((currLine = bufferedReader.readLine()) != null) {
Iterator<TsFileResource> iterator = resource.getUnseqFiles().iterator();
- MergeFileInfo toMatchInfo = MergeFileInfo.getFileInfoFromString(currLine);
+ MergeFileInfo toMatchInfo = null;
+ try {
+ toMatchInfo = MergeFileInfo.getFileInfoFromString(currLine);
+ } catch (InvalidCompactionLogException e) {
+ // the line is invalid, terminate the loop
+ logger.warn("Invalid file info line {}", currLine);
+ break;
+ }
boolean currentFileFound = false;
while (iterator.hasNext()) {
TsFileResource unseqFile = iterator.next();
@@ -164,7 +179,7 @@ public class MergeLogAnalyzer {
.getTsFile()
.getParent()
.replace("sequence", "unsequence"),
- MergeFileInfo.getFileInfoFromString(currLine).filename)));
+ toMatchInfo.filename)));
allSourceFileExists = false;
}
}
diff --git a/server/src/main/java/org/apache/iotdb/db/exception/compaction/CompactionException.java b/server/src/main/java/org/apache/iotdb/db/exception/compaction/CompactionException.java
new file mode 100644
index 0000000000..6294d6bc47
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/exception/compaction/CompactionException.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.db.exception.compaction;
+
+public class CompactionException extends Exception {
+ public CompactionException(String message) {
+ super(message);
+ }
+}
diff --git a/server/src/main/java/org/apache/iotdb/db/exception/compaction/InvalidCompactionLogException.java b/server/src/main/java/org/apache/iotdb/db/exception/compaction/InvalidCompactionLogException.java
new file mode 100644
index 0000000000..b351cbbe49
--- /dev/null
+++ b/server/src/main/java/org/apache/iotdb/db/exception/compaction/InvalidCompactionLogException.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.db.exception.compaction;
+
+public class InvalidCompactionLogException extends CompactionException {
+ public InvalidCompactionLogException(String message) {
+ super(message);
+ }
+}