You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/12/09 01:39:27 UTC

[GitHub] [iotdb] qiaojialin commented on a change in pull request #4498: [IOTDB-2039] Fix data redundant after too many open files exception occurs during compaction

qiaojialin commented on a change in pull request #4498:
URL: https://github.com/apache/iotdb/pull/4498#discussion_r765370968



##########
File path: server/src/main/java/org/apache/iotdb/db/engine/compaction/inner/sizetiered/SizeTieredCompactionTask.java
##########
@@ -233,4 +215,149 @@ public boolean checkValidAndSetMerging() {
     }
     return true;
   }
+
+  public void handleException(File logFile, TsFileResource targetTsFile) {
+    boolean handleSuccess = true;
+    if (logFile.exists()) {
+      // if the compaction log file does not exist
+      // it means the compaction process didn't start yet
+      // we need not to handle it
+      boolean allSourceFileExist = true;
+      List<TsFileResource> lostSourceFiles = new ArrayList<>();
+      for (TsFileResource sourceTsFile : selectedTsFileResourceList) {
+        if (!sourceTsFile.getTsFile().exists()) {
+          allSourceFileExist = false;
+          lostSourceFiles.add(sourceTsFile);
+        }
+      }
+      if (allSourceFileExist) {
+        // all source file exists, delete the target file
+        LOGGER.info(
+            "{} [Compaction][ExceptionHandler] all source files {} exists, delete target file {}",
+            fullStorageGroupName,
+            selectedTsFileResourceList,
+            targetTsFile);
+        targetTsFile.remove();
+        if (targetTsFile.getTsFile().exists()) {
+          LOGGER.warn(
+              "{} [Compaction][ExceptionHandler] failed to remove target file {}, set allowCompaction to false",
+              fullStorageGroupName,
+              targetTsFile);
+          tsFileManager.setAllowCompaction(false);
+          handleSuccess = false;
+        } else {
+          for (TsFileResource tsFileResource : selectedTsFileResourceList) {

Review comment:
       add javadoc




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org