From 5b4e69c059230f4222fc68c387f02cde2f2b3958 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 19 Mar 2024 11:57:38 +0100 Subject: [PATCH] MDEV-23224 Windows threadpool - use better threadpool_max_threads default. Use max_connections in calculation, top prevent possible deadlock, if max_connection is high. --- sql/threadpool_win.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sql/threadpool_win.cc b/sql/threadpool_win.cc index ed68e31c755..65e40598135 100644 --- a/sql/threadpool_win.cc +++ b/sql/threadpool_win.cc @@ -355,10 +355,13 @@ int TP_pool_win::init() if (IS_SYSVAR_AUTOSIZE(&threadpool_max_threads)) { /* - Nr 500 comes from Microsoft documentation, - there is no API for GetThreadpoolThreadMaxThreads() + Default 500 comes from Microsoft documentation, + there is no API for GetThreadpoolThreadMaxThreads(). + + To avoid deadlocks, allow at least max_connections + safety + margin threads in the pool. */ - SYSVAR_AUTOSIZE(threadpool_max_threads,500); + SYSVAR_AUTOSIZE(threadpool_max_threads,std::max(500U,(uint)max_connections + 10)); } else {