Commit 3dd91241 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-24985 Shutdown fails to abort current InnoDB lock waits

On shutdown, to kill remaining connections, do the same thing that
server does during KILL CONNECTION, i.e thd->awake().

The stripped-down KILL version, that was used prior to this patch
for shutdown, missed the engine specific part (ha_kill_query)
parent 4555fb17
......@@ -660,6 +660,7 @@ SHOW_COMP_OPTION have_openssl;
#ifndef EMBEDDED_LIBRARY
static std::atomic<char*> shutdown_user;
#endif //EMBEDDED_LIBRARY
std::atomic<my_thread_id> shutdown_thread_id;
/* Thread specific variables */
......@@ -1532,10 +1533,7 @@ static my_bool kill_thread_phase_1(THD *thd, void *)
if (DBUG_EVALUATE_IF("only_kill_system_threads", !thd->system_thread, 0))
return 0;
thd->set_killed(KILL_SERVER_HARD);
MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (thd));
kill_thread(thd);
thd->awake(KILL_SERVER_HARD);
return 0;
}
......@@ -1666,6 +1664,7 @@ void kill_mysql(THD *thd)
my_free(user);
}
shutdown_thread_id= thd->thread_id;
DBUG_EXECUTE_IF("mysql_admin_shutdown_wait_for_slaves",
thd->lex->is_shutdown_wait_for_slaves= true;);
DBUG_EXECUTE_IF("simulate_delay_at_shutdown",
......
......@@ -1869,7 +1869,7 @@ void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var,
@note Do always call this while holding LOCK_thd_kill.
NOT_KILLED is used to awake a thread for a slave
*/
extern std::atomic<my_thread_id> shutdown_thread_id;
void THD::awake_no_mutex(killed_state state_to_set)
{
DBUG_ENTER("THD::awake");
......@@ -1893,7 +1893,7 @@ void THD::awake_no_mutex(killed_state state_to_set)
if (state_to_set >= KILL_CONNECTION || state_to_set == NOT_KILLED)
{
#ifdef SIGNAL_WITH_VIO_CLOSE
if (this != current_thd)
if (this != current_thd && thread_id != shutdown_thread_id)
{
if(active_vio)
vio_shutdown(active_vio, SHUT_RDWR);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment