You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2025/04/30 02:31:46 UTC

(iotdb) 01/01: Interrupt wal-delete thread when WALManager is closed

This is an automated email from the ASF dual-hosted git repository.

jiangtian pushed a commit to branch interrupt_wal_thread
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 0bd27e12d4f2d6df33826c6c50712bb49018f72a
Author: Tian Jiang <jt...@163.com>
AuthorDate: Wed Apr 30 10:31:32 2025 +0800

    Interrupt wal-delete thread when WALManager is closed
---
 .../org/apache/iotdb/db/storageengine/dataregion/wal/WALManager.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/WALManager.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/WALManager.java
index a048438f005..7d9f7bb4679 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/WALManager.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/WALManager.java
@@ -166,6 +166,7 @@ public class WALManager implements IService {
     logger.info("Start rebooting wal delete thread.");
     if (walDeleteThread != null) {
       shutdownThread(walDeleteThread, ThreadName.WAL_DELETE);
+      walDeleteThread = null;
     }
     logger.info("Stop wal delete thread successfully, and now restart it.");
     registerScheduleTask(0, config.getDeleteWalFilesPeriodInMs());
@@ -179,7 +180,7 @@ public class WALManager implements IService {
     // threshold, the system continues to delete expired files until the disk size is smaller than
     // the threshold.
     boolean firstLoop = true;
-    while (firstLoop || shouldThrottle()) {
+    while ((firstLoop || shouldThrottle()) && !Thread.interrupted()) {
       deleteOutdatedFilesInWALNodes();
       if (firstLoop && shouldThrottle()) {
         logger.warn(
@@ -275,7 +276,7 @@ public class WALManager implements IService {
   }
 
   private void shutdownThread(ExecutorService thread, ThreadName threadName) {
-    thread.shutdown();
+    thread.shutdownNow();
     try {
       if (!thread.awaitTermination(30, TimeUnit.SECONDS)) {
         logger.warn("Waiting thread {} to be terminated is timeout", threadName.getName());