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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to