Commit 283efe26 authored by Daniele Sciascia's avatar Daniele Sciascia Committed by Jan Lindström

MDEV-29878 Galera test failure on MDEV-26575

Test MDEV-26575 fails when it runs after MDEV-25389. This is because
the latter simulates a failure while an applier thread is
created in `start_wsrep_THD()`. The failure was not handled correctly
and would not cleanup the created THD from the global
`server_threads`. A subsequent shutdown would hang and eventually fail
trying to close this THD.
Reviewed-by: default avatarJan Lindström <jan.lindstrom@mariadb.com>
parent 97d9bf98
connection node_2; connection node_2;
connection node_1; connection node_1;
connection node_1;
connection node_2;
connection node_2; connection node_2;
call mtr.add_suppression("WSREP: Failed to create/initialize system thread"); call mtr.add_suppression("WSREP: Failed to create/initialize system thread");
SET GLOBAL debug_dbug='+d,simulate_failed_connection_1'; SET GLOBAL debug_dbug='+d,simulate_failed_connection_1';
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
--source include/have_debug.inc --source include/have_debug.inc
--source include/have_debug_sync.inc --source include/have_debug_sync.inc
--let $node_1=node_1
--let $node_2=node_2
--source ../galera/include/auto_increment_offset_save.inc
--connection node_2 --connection node_2
call mtr.add_suppression("WSREP: Failed to create/initialize system thread"); call mtr.add_suppression("WSREP: Failed to create/initialize system thread");
SET GLOBAL debug_dbug='+d,simulate_failed_connection_1'; SET GLOBAL debug_dbug='+d,simulate_failed_connection_1';
...@@ -11,3 +15,10 @@ SELECT @@wsrep_slave_threads; ...@@ -11,3 +15,10 @@ SELECT @@wsrep_slave_threads;
SET GLOBAL debug_dbug=''; SET GLOBAL debug_dbug='';
SET GLOBAL wsrep_slave_threads=1; SET GLOBAL wsrep_slave_threads=1;
SELECT @@wsrep_slave_threads; SELECT @@wsrep_slave_threads;
# MDEV-29878: this test caused a subsequent test to fail
# during shutdown. Do a restart here, to make sure the
# issue is fixed.
--source include/restart_mysqld.inc
--source ../galera/include/auto_increment_offset_restore.inc
...@@ -2901,7 +2901,7 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len) ...@@ -2901,7 +2901,7 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len)
void* start_wsrep_THD(void *arg) void* start_wsrep_THD(void *arg)
{ {
THD *thd; THD *thd= NULL;
Wsrep_thd_args* thd_args= (Wsrep_thd_args*) arg; Wsrep_thd_args* thd_args= (Wsrep_thd_args*) arg;
...@@ -2939,10 +2939,6 @@ void* start_wsrep_THD(void *arg) ...@@ -2939,10 +2939,6 @@ void* start_wsrep_THD(void *arg)
thd->thr_create_utime= microsecond_interval_timer(); thd->thr_create_utime= microsecond_interval_timer();
if (MYSQL_CALLBACK_ELSE(thread_scheduler, init_new_connection_thread, (), 0)) if (MYSQL_CALLBACK_ELSE(thread_scheduler, init_new_connection_thread, (), 0))
{ {
close_connection(thd, ER_OUT_OF_RESOURCES);
statistic_increment(aborted_connects,&LOCK_status);
// This will signal error to wsrep_slave_threads_update
wsrep_thread_create_failed.store(true, std::memory_order_relaxed);
WSREP_DEBUG("start_wsrep_THD: init_new_connection_thread failed"); WSREP_DEBUG("start_wsrep_THD: init_new_connection_thread failed");
goto error; goto error;
} }
...@@ -2964,11 +2960,6 @@ void* start_wsrep_THD(void *arg) ...@@ -2964,11 +2960,6 @@ void* start_wsrep_THD(void *arg)
wsrep_assign_from_threadvars(thd); wsrep_assign_from_threadvars(thd);
if (wsrep_store_threadvars(thd)) if (wsrep_store_threadvars(thd))
{ {
close_connection(thd, ER_OUT_OF_RESOURCES);
statistic_increment(aborted_connects,&LOCK_status);
MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));
delete thd;
delete thd_args;
goto error; goto error;
} }
...@@ -3061,6 +3052,18 @@ void* start_wsrep_THD(void *arg) ...@@ -3061,6 +3052,18 @@ void* start_wsrep_THD(void *arg)
error: error:
WSREP_ERROR("Failed to create/initialize system thread"); WSREP_ERROR("Failed to create/initialize system thread");
if (thd)
{
close_connection(thd, ER_OUT_OF_RESOURCES);
statistic_increment(aborted_connects, &LOCK_status);
server_threads.erase(thd);
delete thd;
my_thread_end();
}
delete thd_args;
// This will signal error to wsrep_slave_threads_update
wsrep_thread_create_failed.store(true, std::memory_order_relaxed);
/* Abort if its the first applier/rollbacker thread. */ /* Abort if its the first applier/rollbacker thread. */
if (!mysqld_server_initialized) if (!mysqld_server_initialized)
unireg_abort(1); unireg_abort(1);
......
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
#include "rpl_rli.h" #include "rpl_rli.h"
#include "log_event.h" #include "log_event.h"
#include "sql_parse.h" #include "sql_parse.h"
#include "mysqld.h" // start_wsrep_THD(); #include "wsrep_mysqld.h" // start_wsrep_THD();
#include "wsrep_applier.h" // start_wsrep_THD();
#include "mysql/service_wsrep.h" #include "mysql/service_wsrep.h"
#include "debug_sync.h" #include "debug_sync.h"
#include "slave.h" #include "slave.h"
......
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