From 00ddc8bc7c003122bc424929f2a85872dbd8b813 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 9 Oct 2018 18:06:22 +0100 Subject: MDEV-17413 Crash in my_malloc_size_cb_func() during shutdown with forceful connection close. Fix is to ensure that when close_connection() is called from shutdown thread, current_thd is set. This that allocation callback for THD specific memory won't assert(in debug version), or crash (in 10.1 and later) close_connection() allocates THD specific memory e.g when it writes the final error packet, and compression is ON for the connection. --- sql/mysqld.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 9643f0699d1..6ac54d59ee4 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1699,7 +1699,14 @@ static void close_connections(void) tmp->thread_id, (tmp->main_security_ctx.user ? tmp->main_security_ctx.user : "")); + /* + close_connection() might need a valid current_thd + for memory allocation tracking. + */ + THD* save_thd= current_thd; + set_current_thd(tmp); close_connection(tmp,ER_SERVER_SHUTDOWN); + set_current_thd(save_thd); } #endif DBUG_PRINT("quit",("Unlocking LOCK_thread_count")); -- cgit v1.2.1 From 5936d43afb6ad5a75d9eed17eb39e8c00a08a684 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 2 Feb 2018 14:24:36 +1100 Subject: threadpool_size can contribute to the wanted_files --- sql/mysqld.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6ac54d59ee4..32253e60791 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4088,6 +4088,10 @@ static int init_common_variables() /* MyISAM requires two file handles per table. */ wanted_files= (10 + max_connections + extra_max_connections + tc_size * 2); +#if defined(HAVE_POOL_OF_THREADS) && !defined(__WIN__) + // add epoll or kevent fd for each threadpool group, in case pool of threads is used + wanted_file+= (thread_handling > SCHEDULER_NO_THREADS) ? 0 : threadpool_size; +#endif /* We are trying to allocate no less than max_connections*5 file handles (i.e. we are trying to set the limit so that they will -- cgit v1.2.1 From 0f178e7cae4fed9a01d73a398c012fd0e62160f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 12 Oct 2018 13:51:37 +0300 Subject: Fix typo in 5936d43afb6ad5a75d9eed17eb39e8c00a08a684 --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/mysqld.cc') diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 32253e60791..21bfc3cead2 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4090,7 +4090,7 @@ static int init_common_variables() tc_size * 2); #if defined(HAVE_POOL_OF_THREADS) && !defined(__WIN__) // add epoll or kevent fd for each threadpool group, in case pool of threads is used - wanted_file+= (thread_handling > SCHEDULER_NO_THREADS) ? 0 : threadpool_size; + wanted_files+= (thread_handling > SCHEDULER_NO_THREADS) ? 0 : threadpool_size; #endif /* We are trying to allocate no less than max_connections*5 file -- cgit v1.2.1