Skip to content

Commit 283efe2

Browse files
Daniele Sciasciajanlindstrom
authored andcommitted
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>
1 parent 97d9bf9 commit 283efe2

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

mysql-test/suite/galera/r/MDEV-25389.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
connection node_2;
22
connection node_1;
3+
connection node_1;
4+
connection node_2;
35
connection node_2;
46
call mtr.add_suppression("WSREP: Failed to create/initialize system thread");
57
SET GLOBAL debug_dbug='+d,simulate_failed_connection_1';

mysql-test/suite/galera/t/MDEV-25389.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
--source include/have_debug.inc
33
--source include/have_debug_sync.inc
44

5+
--let $node_1=node_1
6+
--let $node_2=node_2
7+
--source ../galera/include/auto_increment_offset_save.inc
8+
59
--connection node_2
610
call mtr.add_suppression("WSREP: Failed to create/initialize system thread");
711
SET GLOBAL debug_dbug='+d,simulate_failed_connection_1';
@@ -11,3 +15,10 @@ SELECT @@wsrep_slave_threads;
1115
SET GLOBAL debug_dbug='';
1216
SET GLOBAL wsrep_slave_threads=1;
1317
SELECT @@wsrep_slave_threads;
18+
19+
# MDEV-29878: this test caused a subsequent test to fail
20+
# during shutdown. Do a restart here, to make sure the
21+
# issue is fixed.
22+
--source include/restart_mysqld.inc
23+
24+
--source ../galera/include/auto_increment_offset_restore.inc

sql/wsrep_mysqld.cc

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2901,7 +2901,7 @@ int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len)
29012901

29022902
void* start_wsrep_THD(void *arg)
29032903
{
2904-
THD *thd;
2904+
THD *thd= NULL;
29052905

29062906
Wsrep_thd_args* thd_args= (Wsrep_thd_args*) arg;
29072907

@@ -2939,10 +2939,6 @@ void* start_wsrep_THD(void *arg)
29392939
thd->thr_create_utime= microsecond_interval_timer();
29402940
if (MYSQL_CALLBACK_ELSE(thread_scheduler, init_new_connection_thread, (), 0))
29412941
{
2942-
close_connection(thd, ER_OUT_OF_RESOURCES);
2943-
statistic_increment(aborted_connects,&LOCK_status);
2944-
// This will signal error to wsrep_slave_threads_update
2945-
wsrep_thread_create_failed.store(true, std::memory_order_relaxed);
29462942
WSREP_DEBUG("start_wsrep_THD: init_new_connection_thread failed");
29472943
goto error;
29482944
}
@@ -2964,11 +2960,6 @@ void* start_wsrep_THD(void *arg)
29642960
wsrep_assign_from_threadvars(thd);
29652961
if (wsrep_store_threadvars(thd))
29662962
{
2967-
close_connection(thd, ER_OUT_OF_RESOURCES);
2968-
statistic_increment(aborted_connects,&LOCK_status);
2969-
MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));
2970-
delete thd;
2971-
delete thd_args;
29722963
goto error;
29732964
}
29742965

@@ -3061,6 +3052,18 @@ void* start_wsrep_THD(void *arg)
30613052
error:
30623053
WSREP_ERROR("Failed to create/initialize system thread");
30633054

3055+
if (thd)
3056+
{
3057+
close_connection(thd, ER_OUT_OF_RESOURCES);
3058+
statistic_increment(aborted_connects, &LOCK_status);
3059+
server_threads.erase(thd);
3060+
delete thd;
3061+
my_thread_end();
3062+
}
3063+
delete thd_args;
3064+
// This will signal error to wsrep_slave_threads_update
3065+
wsrep_thread_create_failed.store(true, std::memory_order_relaxed);
3066+
30643067
/* Abort if its the first applier/rollbacker thread. */
30653068
if (!mysqld_server_initialized)
30663069
unireg_abort(1);

sql/wsrep_thd.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
#include "rpl_rli.h"
2424
#include "log_event.h"
2525
#include "sql_parse.h"
26-
#include "mysqld.h" // start_wsrep_THD();
27-
#include "wsrep_applier.h" // start_wsrep_THD();
26+
#include "wsrep_mysqld.h" // start_wsrep_THD();
2827
#include "mysql/service_wsrep.h"
2928
#include "debug_sync.h"
3029
#include "slave.h"

0 commit comments

Comments
 (0)