Commit 351026ca authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Fix threadpool memory leak and connect2 test

parent f12229f6
call mtr.add_suppression("Allocation failed");
SET @old_debug= @@session.debug;
set @old_thread_cache_size=@@global.thread_cache_size;
select 1;
......
......@@ -4,7 +4,7 @@
# This test makes no sense with the embedded server
--source include/not_embedded.inc
--source include/have_debug.inc
call mtr.add_suppression("Allocation failed");
SET @old_debug= @@session.debug;
set @old_thread_cache_size=@@global.thread_cache_size;
......
......@@ -122,13 +122,19 @@ THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data)
pthread_setspecific(THR_KEY_mysys, 0);
my_thread_init();
st_my_thread_var* mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys);
DBUG_EXECUTE_IF("simulate_failed_connection_1", mysys_var= NULL; my_thread_end(););
if (!mysys_var ||!(thd= connect->create_thd()))
{
/* Out of memory? */
connect->close_and_delete();
if (mysys_var)
{
#ifdef HAVE_PSI_INTERFACE
/*
current PSI is still from worker thread.
Set to 0, to avoid premature cleanup by my_thread_end
*/
if (PSI_server) PSI_server->set_thread(0);
#endif
my_thread_end();
}
worker_context.restore();
......
......@@ -1235,6 +1235,7 @@ void tp_add_connection(CONNECT *connect)
connection= alloc_connection();
if (!connection)
{
connect->close_and_delete();
DBUG_VOID_RETURN;
}
connection->connect= connect;
......
......@@ -663,6 +663,7 @@ void tp_add_connection(CONNECT *connect)
{
connection_t *con;
con= (connection_t *)malloc(sizeof(connection_t));
DBUG_EXECUTE_IF("simulate_failed_connection_1", free(con);con= 0; );
if (!con)
{
tp_log_warning("Allocation failed", "tp_add_connection");
......
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