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 2021/08/16 09:20:51 UTC
[iotdb] branch master updated: [IOTDB-1531] Check tsfile creation
time when recovering (#3642)
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/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 7ea4f0d [IOTDB-1531] Check tsfile creation time when recovering (#3642)
7ea4f0d is described below
commit 7ea4f0d6d71bcb72b1e21a5684fdb79ae82707b4
Author: Alan Choo <43...@users.noreply.github.com>
AuthorDate: Mon Aug 16 17:20:26 2021 +0800
[IOTDB-1531] Check tsfile creation time when recovering (#3642)
---
.../engine/storagegroup/StorageGroupProcessor.java | 28 +++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
index 77d68b1..77d89bd 100755
--- a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
@@ -635,7 +635,7 @@ public class StorageGroupProcessor {
@SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning
private Pair<List<TsFileResource>, List<TsFileResource>> getAllFiles(List<String> folders)
- throws IOException {
+ throws IOException, StorageGroupProcessorException {
List<File> tsFiles = new ArrayList<>();
List<File> upgradeFiles = new ArrayList<>();
for (String baseDir : folders) {
@@ -683,10 +683,18 @@ public class StorageGroupProcessor {
}
}
}
+
tsFiles.sort(this::compareFileName);
+ if (!tsFiles.isEmpty()) {
+ checkTsFileTime(tsFiles.get(tsFiles.size() - 1));
+ }
List<TsFileResource> ret = new ArrayList<>();
tsFiles.forEach(f -> ret.add(new TsFileResource(f)));
+
upgradeFiles.sort(this::compareFileName);
+ if (!upgradeFiles.isEmpty()) {
+ checkTsFileTime(upgradeFiles.get(upgradeFiles.size() - 1));
+ }
List<TsFileResource> upgradeRet = new ArrayList<>();
for (File f : upgradeFiles) {
TsFileResource fileResource = new TsFileResource(f);
@@ -712,6 +720,24 @@ public class StorageGroupProcessor {
}
}
+ /** check if the tsfile's time is smaller than system current time */
+ private void checkTsFileTime(File tsFile) throws StorageGroupProcessorException {
+ String[] items = tsFile.getName().replace(TSFILE_SUFFIX, "").split(FILE_NAME_SEPARATOR);
+ long fileTime = Long.parseLong(items[0]);
+ long currentTime = System.currentTimeMillis();
+ if (fileTime > currentTime) {
+ throw new StorageGroupProcessorException(
+ String.format(
+ "virtual storage group %s[%s] is down, because the time of tsfile %s is larger than system current time, "
+ + "file time is %d while system current time is %d, please check it.",
+ logicalStorageGroupName,
+ virtualStorageGroupId,
+ tsFile.getAbsolutePath(),
+ fileTime,
+ currentTime));
+ }
+ }
+
private void recoverTsFiles(List<TsFileResource> tsFiles, boolean isSeq) {
for (int i = 0; i < tsFiles.size(); i++) {
TsFileResource tsFileResource = tsFiles.get(i);