summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2019-02-22 22:28:24 +0100
committerSergey Vojtovich <svoj@mariadb.org>2019-02-26 23:04:42 +0400
commitbba4e7f28795be278816cb904cb2aaa5901fbb9b (patch)
tree9eea09f7d63ab4ed113b5c51eb293236a374df21
parent794c6dd215114e68b648b9a52fcefa4f54904863 (diff)
downloadmariadb-git-bb-10.4-wlad-MDEV18694.tar.gz
MDEV-18694 : Do not call close_connection() on active connections inbb-10.4-wlad-MDEV18694
server shutdown code. Fix fixes a race condition, if an active connection either writes, or will be writing to the socket after it is closed. Previous call to socket shutdown() is fully enough to wake up and idle connection, so that close_connection is obsolete and dangerous.
-rw-r--r--sql/mysqld.cc33
1 files changed, 7 insertions, 26 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index b5c4a87d680..24993a045ac 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1562,27 +1562,12 @@ static my_bool kill_all_threads(THD *thd, void *)
}
-static my_bool kill_all_threads_once_again(THD *thd, void *)
+static my_bool warn_threads_still_active(THD *thd, void *)
{
-#ifndef __bsdi__ // Bug in BSDI kernel
- if (thd->vio_ok())
- {
- if (global_system_variables.log_warnings)
- sql_print_warning(ER_DEFAULT(ER_FORCING_CLOSE), my_progname,
- (ulong) thd->thread_id,
- (thd->main_security_ctx.user ?
- thd->main_security_ctx.user : ""));
- /*
- close_connection() might need a valid current_thd
- for memory allocation tracking.
- */
- THD *save_thd= current_thd;
- set_current_thd(thd);
- close_connection(thd);
- set_current_thd(save_thd);
- }
-#endif
-
+ sql_print_warning("%s: Thread %llu (user : '%s') did not exit\n", my_progname,
+ (ulonglong) thd->thread_id,
+ (thd->main_security_ctx.user ?
+ thd->main_security_ctx.user : ""));
return 0;
}
@@ -1735,12 +1720,8 @@ static void close_connections(void)
for (int i= 0; thread_count && i < 1000; i++)
my_sleep(20000);
- /*
- Force remaining threads to die by closing the connection to the client
- This will ensure that threads that are waiting for a command from the
- client on a blocking read call are aborted.
- */
- server_threads.iterate(kill_all_threads_once_again);
+ if (global_system_variables.log_warnings)
+ server_threads.iterate(warn_threads_still_active);
end_slave();
#ifdef WITH_WSREP