From edeeac84cf0792503c2f9efc65390ce0d735648e Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 30 Mar 2023 20:08:38 +0200 Subject: [PATCH] Fix incorrect ThreadPool usage after ThreadPool introspection ``` $ gg 'ThreadPool[^()]([A-Za-z_]\+,' src/ src/Interpreters/Context.cpp: shared->load_marks_threadpool = std::make_unique(pool_size, pool_size, queue_size); src/Interpreters/Context.cpp: shared->prefetch_threadpool = std::make_unique(pool_size, pool_size, queue_size); src/Interpreters/Context.cpp: shared->threadpool_writer = std::make_unique(pool_size, pool_size, queue_size); ``` Fixes: #47880 Signed-off-by: Azat Khuzhin --- src/Common/CurrentMetrics.cpp | 6 ++++++ src/Interpreters/Context.cpp | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Common/CurrentMetrics.cpp b/src/Common/CurrentMetrics.cpp index 4c773048597..542c48148c8 100644 --- a/src/Common/CurrentMetrics.cpp +++ b/src/Common/CurrentMetrics.cpp @@ -78,6 +78,12 @@ M(BackupsThreadsActive, "Number of threads in thread pool for BACKUP running a task.") \ M(RestoreThreads, "Number of threads in the thread pool for RESTORE.") \ M(RestoreThreadsActive, "Number of threads in the thread pool for RESTORE running a task.") \ + M(MarksLoaderThreads, "Number of threads in thread pool for loading marks.") \ + M(MarksLoaderThreadsActive, "Number of threads in the thread pool for loading marks running a task.") \ + M(IOPrefetchThreads, "Number of threads in the IO prefertch thread pool.") \ + M(IOPrefetchThreadsActive, "Number of threads in the IO prefetch thread pool running a task.") \ + M(IOWriterThreads, "Number of threads in the IO writer thread pool.") \ + M(IOWriterThreadsActive, "Number of threads in the IO writer thread pool running a task.") \ M(IOThreads, "Number of threads in the IO thread pool.") \ M(IOThreadsActive, "Number of threads in the IO thread pool running a task.") \ M(ThreadPoolRemoteFSReaderThreads, "Number of threads in the thread pool for remote_filesystem_read_method=threadpool.") \ diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index 82a8e43e8e2..522107dccc9 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -145,6 +145,12 @@ namespace CurrentMetrics extern const Metric BackgroundFetchesPoolSize; extern const Metric BackgroundCommonPoolTask; extern const Metric BackgroundCommonPoolSize; + extern const Metric MarksLoaderThreads; + extern const Metric MarksLoaderThreadsActive; + extern const Metric IOPrefetchThreads; + extern const Metric IOPrefetchThreadsActive; + extern const Metric IOWriterThreads; + extern const Metric IOWriterThreadsActive; } namespace DB @@ -2018,7 +2024,8 @@ ThreadPool & Context::getLoadMarksThreadpool() const { auto pool_size = config.getUInt(".load_marks_threadpool_pool_size", 50); auto queue_size = config.getUInt(".load_marks_threadpool_queue_size", 1000000); - shared->load_marks_threadpool = std::make_unique(pool_size, pool_size, queue_size); + shared->load_marks_threadpool = std::make_unique( + CurrentMetrics::MarksLoaderThreads, CurrentMetrics::MarksLoaderThreadsActive, pool_size, pool_size, queue_size); } return *shared->load_marks_threadpool; } @@ -2043,7 +2050,8 @@ ThreadPool & Context::getPrefetchThreadpool() const { auto pool_size = getPrefetchThreadpoolSize(); auto queue_size = config.getUInt(".prefetch_threadpool_queue_size", 1000000); - shared->prefetch_threadpool = std::make_unique(pool_size, pool_size, queue_size); + shared->prefetch_threadpool = std::make_unique( + CurrentMetrics::IOPrefetchThreads, CurrentMetrics::IOPrefetchThreadsActive, pool_size, pool_size, queue_size); } return *shared->prefetch_threadpool; } @@ -3967,7 +3975,8 @@ ThreadPool & Context::getThreadPoolWriter() const auto pool_size = config.getUInt(".threadpool_writer_pool_size", 100); auto queue_size = config.getUInt(".threadpool_writer_queue_size", 1000000); - shared->threadpool_writer = std::make_unique(pool_size, pool_size, queue_size); + shared->threadpool_writer = std::make_unique( + CurrentMetrics::IOWriterThreads, CurrentMetrics::IOWriterThreadsActive, pool_size, pool_size, queue_size); } return *shared->threadpool_writer;