Commit 00ddc8bc authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

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.
parent bd219043
...@@ -1699,7 +1699,14 @@ static void close_connections(void) ...@@ -1699,7 +1699,14 @@ static void close_connections(void)
tmp->thread_id, tmp->thread_id,
(tmp->main_security_ctx.user ? (tmp->main_security_ctx.user ?
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); close_connection(tmp,ER_SERVER_SHUTDOWN);
set_current_thd(save_thd);
} }
#endif #endif
DBUG_PRINT("quit",("Unlocking LOCK_thread_count")); DBUG_PRINT("quit",("Unlocking LOCK_thread_count"));
......
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