Skip to content

Commit 0be70a1

Browse files
committed
MDEV-23483: Set Galera SST thd as system thread
Revert change to MDL and set SST donor thread as a system thread. Joiner thread was already a system thread.
1 parent 6fa40b8 commit 0be70a1

File tree

5 files changed

+27
-42
lines changed

5 files changed

+27
-42
lines changed

mysql-test/suite/galera/t/mdev-22543.test

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
--source include/galera_cluster.inc
66
--source include/have_debug.inc
77
--source include/have_debug_sync.inc
8-
8+
99
--let $node_1 = node_1
1010
--let $node_2 = node_2
1111
--source include/auto_increment_offset_save.inc
12-
12+
1313
--let $galera_connection_name = node_1_ctrl
1414
--let $galera_server_number = 1
1515
--source include/galera_connect.inc
16-
16+
1717
#
1818
# Run UPDATE on node_1 and make it block before table locks are taken.
1919
# This should block FTWRL.
@@ -23,10 +23,10 @@ CREATE TABLE t1 (f1 INT PRIMARY KEY, f2 INT);
2323
INSERT INTO t1 VALUES (1, 1);
2424
SET DEBUG_SYNC = "before_lock_tables_takes_lock SIGNAL sync_point_reached WAIT_FOR sync_point_continue";
2525
--send UPDATE t1 SET f2 = 2 WHERE f1 = 1
26-
26+
2727
--connection node_1_ctrl
2828
SET DEBUG_SYNC = "now WAIT_FOR sync_point_reached";
29-
29+
3030
#
3131
# Restart node_2, force SST.
3232
#
@@ -40,19 +40,19 @@ SET DEBUG_SYNC = "now WAIT_FOR sync_point_reached";
4040
# If the bug is present, FTWRL times out on node_1 in couple of
4141
# seconds and node_2 fails to join.
4242
--sleep 10
43-
43+
4444
--connection node_1_ctrl
4545
SET DEBUG_SYNC = "now SIGNAL sync_point_continue";
46-
46+
4747
--connection node_1
4848
--reap
4949
SET DEBUG_SYNC = "RESET";
50-
50+
5151
--connection node_2
5252
--enable_reconnect
5353
--source include/wait_until_connected_again.inc
54-
54+
5555
--connection node_1
5656
DROP TABLE t1;
57-
57+
5858
--source include/auto_increment_offset_restore.inc

sql/mdl.cc

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <mysql/psi/mysql_stage.h>
2626
#include "wsrep_mysqld.h"
2727
#include "wsrep_thd.h"
28-
#include "wsrep_sst.h"
2928

3029
#ifdef HAVE_PSI_INTERFACE
3130
static PSI_mutex_key key_MDL_wait_LOCK_wait_status;
@@ -2138,26 +2137,18 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout)
21382137
wait_status= m_wait.timed_wait(m_owner, &abs_shortwait, FALSE,
21392138
mdl_request->key.get_wait_state_name());
21402139

2141-
THD* thd= m_owner->get_thd();
2142-
21432140
if (wait_status != MDL_wait::EMPTY)
21442141
break;
21452142
/* Check if the client is gone while we were waiting. */
2146-
if (! thd_is_connected(thd))
2143+
if (! thd_is_connected(m_owner->get_thd()))
21472144
{
2148-
#if defined(WITH_WSREP) && !defined(EMBEDDED_LIBRARY)
2149-
// During SST client might not be connected
2150-
if (!wsrep_is_sst_progress())
2151-
#endif
2152-
{
2153-
/*
2154-
* The client is disconnected. Don't wait forever:
2155-
* assume it's the same as a wait timeout, this
2156-
* ensures all error handling is correct.
2157-
*/
2158-
wait_status= MDL_wait::TIMEOUT;
2159-
break;
2160-
}
2145+
/*
2146+
* The client is disconnected. Don't wait forever:
2147+
* assume it's the same as a wait timeout, this
2148+
* ensures all error handling is correct.
2149+
*/
2150+
wait_status= MDL_wait::TIMEOUT;
2151+
break;
21612152
}
21622153

21632154
mysql_prlock_wrlock(&lock->m_rwlock);

sql/wsrep_sst.cc

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2008-2015 Codership Oy <http://www.codership.com>
1+
/* Copyright 2008-2020 Codership Oy <http://www.codership.com>
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -192,7 +192,6 @@ bool wsrep_before_SE()
192192

193193
static bool sst_complete = false;
194194
static bool sst_needed = false;
195-
static bool sst_in_progress = false;
196195

197196
#define WSREP_EXTEND_TIMEOUT_INTERVAL 30
198197
#define WSREP_TIMEDWAIT_SECONDS 10
@@ -1545,11 +1544,11 @@ static void* sst_donor_thread (void* a)
15451544
wsrep_uuid_t ret_uuid= WSREP_UUID_UNDEFINED;
15461545
// seqno of complete SST
15471546
wsrep_seqno_t ret_seqno= WSREP_SEQNO_UNDEFINED;
1548-
// SST is now in progress
1549-
sst_in_progress= true;
15501547

1551-
wsp::thd thd(FALSE); // we turn off wsrep_on for this THD so that it can
1552-
// operate with wsrep_ready == OFF
1548+
// We turn off wsrep_on for this THD so that it can
1549+
// operate with wsrep_ready == OFF
1550+
// We also set this SST thread THD as system thread
1551+
wsp::thd thd(FALSE, true);
15531552
wsp::process proc(arg->cmd, "r", arg->env);
15541553

15551554
err= proc.error();
@@ -1648,8 +1647,6 @@ static void* sst_donor_thread (void* a)
16481647
wsrep->sst_sent (wsrep, &state_id, -err);
16491648
proc.wait();
16501649

1651-
sst_in_progress= false;
1652-
16531650
return NULL;
16541651
}
16551652

@@ -1824,8 +1821,3 @@ void wsrep_SE_initialized()
18241821
{
18251822
SE_initialized = true;
18261823
}
1827-
1828-
bool wsrep_is_sst_progress()
1829-
{
1830-
return (sst_in_progress);
1831-
}

sql/wsrep_utils.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,14 +413,16 @@ process::wait ()
413413
return err_;
414414
}
415415

416-
thd::thd (my_bool won) : init(), ptr(new THD(0))
416+
thd::thd (my_bool won, bool system_thread) : init(), ptr(new THD(0))
417417
{
418418
if (ptr)
419419
{
420420
ptr->thread_stack= (char*) &ptr;
421421
ptr->store_globals();
422422
ptr->variables.option_bits&= ~OPTION_BIN_LOG; // disable binlog
423423
ptr->variables.wsrep_on = won;
424+
if (system_thread)
425+
ptr->system_thread= SYSTEM_THREAD_GENERIC;
424426
ptr->security_ctx->master_access= ~(ulong)0;
425427
lex_start(ptr);
426428
}

sql/wsrep_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ class thd
298298

299299
public:
300300

301-
thd(my_bool wsrep_on);
301+
thd(my_bool wsrep_on, bool system_thread=false);
302302
~thd();
303303
THD* const ptr;
304304
};

0 commit comments

Comments
 (0)