Skip to content
Permalink
Browse files
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: Jan Lindström <jan.lindstrom@mariadb.com>
  • Loading branch information
sciascid authored and Jan Lindström committed Nov 29, 2022
1 parent 97d9bf9 commit 283efe2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
@@ -1,5 +1,7 @@
connection node_2;
connection node_1;
connection node_1;
connection node_2;
connection node_2;
call mtr.add_suppression("WSREP: Failed to create/initialize system thread");
SET GLOBAL debug_dbug='+d,simulate_failed_connection_1';
@@ -2,6 +2,10 @@
--source include/have_debug.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
call mtr.add_suppression("WSREP: Failed to create/initialize system thread");
SET GLOBAL debug_dbug='+d,simulate_failed_connection_1';
@@ -11,3 +15,10 @@ SELECT @@wsrep_slave_threads;
SET GLOBAL debug_dbug='';
SET GLOBAL wsrep_slave_threads=1;
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)

void* start_wsrep_THD(void *arg)
{
THD *thd;
THD *thd= NULL;

Wsrep_thd_args* thd_args= (Wsrep_thd_args*) arg;

@@ -2939,10 +2939,6 @@ void* start_wsrep_THD(void *arg)
thd->thr_create_utime= microsecond_interval_timer();
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");
goto error;
}
@@ -2964,11 +2960,6 @@ void* start_wsrep_THD(void *arg)
wsrep_assign_from_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;
}

@@ -3061,6 +3052,18 @@ void* start_wsrep_THD(void *arg)
error:
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. */
if (!mysqld_server_initialized)
unireg_abort(1);
@@ -23,8 +23,7 @@
#include "rpl_rli.h"
#include "log_event.h"
#include "sql_parse.h"
#include "mysqld.h" // start_wsrep_THD();
#include "wsrep_applier.h" // start_wsrep_THD();
#include "wsrep_mysqld.h" // start_wsrep_THD();
#include "mysql/service_wsrep.h"
#include "debug_sync.h"
#include "slave.h"

0 comments on commit 283efe2

Please sign in to comment.