From b0a3b87ee35c338d3b8311247323aba027aaa6d1 Mon Sep 17 00:00:00 2001 From: Jingsong Lee Date: Wed, 17 Jul 2024 15:36:55 +0800 Subject: [PATCH] [core] Fix cache thread pool in FileDeletionThreadPool (#3767) --- .../paimon/utils/FileDeletionThreadPool.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/paimon-common/src/main/java/org/apache/paimon/utils/FileDeletionThreadPool.java b/paimon-common/src/main/java/org/apache/paimon/utils/FileDeletionThreadPool.java index 51b208930201..07b0f5d320c2 100644 --- a/paimon-common/src/main/java/org/apache/paimon/utils/FileDeletionThreadPool.java +++ b/paimon-common/src/main/java/org/apache/paimon/utils/FileDeletionThreadPool.java @@ -44,12 +44,15 @@ public static synchronized ThreadPoolExecutor getExecutorService(int threadNum) } private static ThreadPoolExecutor createCachedThreadPool(int threadNum) { - return new ThreadPoolExecutor( - 0, - threadNum, - 1, - TimeUnit.MINUTES, - new LinkedBlockingQueue<>(), - newDaemonThreadFactory("DELETE-FILE-THREAD-POOL")); + ThreadPoolExecutor executor = + new ThreadPoolExecutor( + threadNum, + threadNum, + 1, + TimeUnit.MINUTES, + new LinkedBlockingQueue<>(), + newDaemonThreadFactory("DELETE-FILE-THREAD-POOL")); + executor.allowCoreThreadTimeOut(true); + return executor; } }