jt2594838 commented on code in PR #14538:
URL: https://github.com/apache/iotdb/pull/14538#discussion_r1897139997


##########
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/storageengine/dataregion/compaction/CompactionWorkerTest.java:
##########
@@ -261,4 +266,30 @@ public void testFailedToCheckValidInInnerTask() throws 
InterruptedException {
     thread.interrupt();
     thread.join();
   }
+
+  @Test
+  public void testAbortCompactionTask() {
+    AtomicReference<CompactionWorker.CompactionTaskFuture> 
compactionTaskSummary =
+        new AtomicReference<>();
+    AtomicBoolean isInterrupted = new AtomicBoolean(false);
+    Phaser phaser = new Phaser(2);
+    Thread t =
+        new Thread(
+            () -> {
+              compactionTaskSummary.set(
+                  new CompactionWorker.CompactionTaskFuture(new 
CompactionTaskSummary()));
+              phaser.arriveAndAwaitAdvance();
+              try {
+                Thread.sleep(10000);

Review Comment:
   This can be unstable. If the test is hung up for 10s or there is a clock 
problem in the test machine, this test is likely to fail.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/compaction/execute/performer/impl/FastCompactionPerformer.java:
##########
@@ -286,6 +286,19 @@ private void compactNonAlignedSeries(
           throw (StopReadTsFileByInterruptException) cause;
         }
         throw new IOException("[Compaction] SubCompactionTask meet errors ", 
e);
+      } catch (InterruptedException e) {
+        abortAllSubTasks(futures);
+        throw e;
+      }
+    }
+  }
+
+  private void abortAllSubTasks(List<Future<Void>> futures) {
+    for (Future<Void> future : futures) {
+      future.cancel(true);
+      try {
+        future.get();
+      } catch (Exception ignored) {
       }
     }

Review Comment:
   Maybe we can cancel them all first and then wait for them.



-- 
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