From 1e3af614b155f74f3ba8281b97765c4e6cf7cbf2 Mon Sep 17 00:00:00 2001 From: zhengyu Date: Sun, 4 Feb 2024 14:40:59 +0800 Subject: [PATCH] [fix](stats) keep threads in pool alive to maintain reasonable parallelism (#30451) --- .../main/java/org/apache/doris/common/ThreadPoolManager.java | 2 +- .../java/org/apache/doris/statistics/AnalysisManager.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/ThreadPoolManager.java b/fe/fe-core/src/main/java/org/apache/doris/common/ThreadPoolManager.java index ed3c32dba19b12..3be5af8ac54eba 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/ThreadPoolManager.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/ThreadPoolManager.java @@ -73,7 +73,7 @@ public class ThreadPoolManager { private static String[] poolMetricTypes = {"pool_size", "active_thread_num", "task_in_queue"}; - private static final long KEEP_ALIVE_TIME = 60L; + public static final long KEEP_ALIVE_TIME = 60L; public static void registerAllThreadPoolMetric() { for (Map.Entry entry : nameToThreadPoolMap.entrySet()) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/statistics/AnalysisManager.java b/fe/fe-core/src/main/java/org/apache/doris/statistics/AnalysisManager.java index 051dcfbb1b5420..90cb0cd5f6d9ac 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/statistics/AnalysisManager.java +++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/AnalysisManager.java @@ -40,6 +40,7 @@ import org.apache.doris.common.DdlException; import org.apache.doris.common.FeConstants; import org.apache.doris.common.FeMetaVersion; +import org.apache.doris.common.ThreadPoolManager; import org.apache.doris.common.ThreadPoolManager.BlockedPolicy; import org.apache.doris.common.io.Text; import org.apache.doris.common.io.Writable; @@ -645,7 +646,8 @@ private ThreadPoolExecutor createThreadPoolForSyncAnalyze() { String poolName = "SYNC ANALYZE THREAD POOL"; return new ThreadPoolExecutor(0, ConnectContext.get().getSessionVariable().parallelSyncAnalyzeTaskNum, - 0, TimeUnit.SECONDS, + ThreadPoolManager.KEEP_ALIVE_TIME, + TimeUnit.SECONDS, new LinkedBlockingQueue<>(), new ThreadFactoryBuilder().setDaemon(true).setNameFormat("SYNC ANALYZE" + "-%d") .build(), new BlockedPolicy(poolName,