mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
MDEV-18694 : Do not call close_connection() on active connections in
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.
This commit is contained in:
parent
794c6dd215
commit
bba4e7f287
1 changed files with 7 additions and 26 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue