Skip to content

Commit d0116e1

Browse files
committed
Revert MDEV-18464 and MDEV-12009
This reverts commit 21b2fad and commit 81d71ee. The MDEV-18464 change introduces a few data race issues. Contrary to the documentation, the field trx_t::victim is not always being protected by lock_sys_t::mutex and trx_t::mutex. Most importantly, it seems that KILL QUERY could wrongly avoid acquiring both mutexes when invoking lock_trx_handle_wait_low(), in case another thread had already set trx->victim=true. We also revert MDEV-12009, because it should depend on the MDEV-18464 fix being present.
1 parent 81d71ee commit d0116e1

File tree

22 files changed

+178
-194
lines changed

22 files changed

+178
-194
lines changed

include/mysql/service_wsrep.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ extern struct wsrep_service_st {
112112
int (*wsrep_trx_order_before_func)(MYSQL_THD, MYSQL_THD);
113113
void (*wsrep_unlock_rollback_func)();
114114
void (*wsrep_set_data_home_dir_func)(const char *data_dir);
115-
my_bool (*wsrep_thd_is_applier_func)(THD *thd);
116115
} *wsrep_service;
117116

118117
#ifdef MYSQL_DYNAMIC_PLUGIN
@@ -156,7 +155,6 @@ extern struct wsrep_service_st {
156155
#define wsrep_trx_order_before(T1,T2) wsrep_service->wsrep_trx_order_before_func(T1,T2)
157156
#define wsrep_unlock_rollback() wsrep_service->wsrep_unlock_rollback_func()
158157
#define wsrep_set_data_home_dir(A) wsrep_service->wsrep_set_data_home_dir_func(A)
159-
#define wsrep_thd_is_applier(T) wsrep_service->wsrep_thd_is_applier_func(T)
160158

161159
#define wsrep_debug get_wsrep_debug()
162160
#define wsrep_log_conflicts get_wsrep_log_conflicts()
@@ -216,7 +214,6 @@ void wsrep_thd_set_conflict_state(THD *thd, enum wsrep_conflict_state state);
216214
bool wsrep_thd_ignore_table(THD *thd);
217215
void wsrep_unlock_rollback();
218216
void wsrep_set_data_home_dir(const char *data_dir);
219-
my_bool wsrep_thd_is_applier(THD *thd);
220217

221218
#endif
222219

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
CREATE USER foo@localhost;
2-
GRANT SELECT on test.* TO foo@localhost;
3-
# Open connection to the 1st node using 'test_user1' user.
41
Got one of the listed errors
52
Got one of the listed errors
63
Got one of the listed errors
74
Got one of the listed errors
8-
DROP USER foo@localhost;

mysql-test/suite/galera/t/galera_kill_applier.cnf

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,26 @@
11
#
22
# This test checks that applier threads are immune to KILL QUERY and KILL STATEMENT
3-
# when USER is not SUPER
43
#
54

65
--source include/galera_cluster.inc
6+
--source include/have_innodb.inc
77

88
--connection node_1
99

10-
CREATE USER foo@localhost;
11-
GRANT SELECT on test.* TO foo@localhost;
12-
1310
--let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE != 'wsrep aborter idle' OR STATE IS NULL LIMIT 1`
1411

15-
--let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
16-
17-
--echo # Open connection to the 1st node using 'test_user1' user.
18-
--let $port_1= \$NODE_MYPORT_1
19-
--connect(foo_node_1,localhost,foo,,test,$port_1,)
20-
21-
--connection foo_node_1
22-
2312
--disable_query_log
2413
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
2514
--eval KILL $applier_thread
2615

2716
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
2817
--eval KILL QUERY $applier_thread
2918

30-
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
31-
--eval KILL $aborter_thread
32-
33-
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
34-
--eval KILL QUERY $aborter_thread
35-
--enable_query_log
36-
37-
#
38-
# SUPER can kill applier threads
39-
#
40-
--connection node_2
41-
42-
--let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE != 'wsrep aborter idle' OR STATE IS NULL LIMIT 1`
43-
44-
--disable_query_log
45-
--eval KILL $applier_thread
46-
--enable_query_log
47-
4819
--let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
4920

50-
--disable_query_log
21+
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
5122
--eval KILL $aborter_thread
52-
--enable_query_log
53-
54-
--source include/restart_mysqld.inc
5523

56-
--connection node_2
57-
--let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE != 'wsrep aborter idle' OR STATE IS NULL LIMIT 1`
58-
59-
--disable_query_log
60-
--eval KILL QUERY $applier_thread
61-
--enable_query_log
62-
63-
--let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
64-
65-
--disable_query_log
24+
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
6625
--eval KILL QUERY $aborter_thread
6726
--enable_query_log
68-
69-
--source include/restart_mysqld.inc
70-
71-
--connection node_1
72-
--disconnect foo_node_1
73-
DROP USER foo@localhost;
74-

sql/sql_parse.cc

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8292,19 +8292,11 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ
82928292
It's ok to also kill DELAYED threads with KILL_CONNECTION instead of
82938293
KILL_SYSTEM_THREAD; The difference is that KILL_CONNECTION may be
82948294
faster and do a harder kill than KILL_SYSTEM_THREAD;
8295-
8296-
Note that if thread is wsrep Brute Force or applier thread we
8297-
allow killing it only when we're SUPER.
82988295
*/
82998296

8300-
if ((thd->security_ctx->master_access & SUPER_ACL) ||
8301-
(thd->security_ctx->user_matches(tmp->security_ctx)
8302-
#ifdef WITH_WSREP
8303-
&&
8304-
!tmp->wsrep_applier &&
8305-
!wsrep_thd_is_BF(tmp, false)
8306-
#endif
8307-
))
8297+
if (((thd->security_ctx->master_access & SUPER_ACL) ||
8298+
thd->security_ctx->user_matches(tmp->security_ctx)) &&
8299+
!wsrep_thd_is_BF(tmp, false))
83088300
{
83098301
tmp->awake(kill_signal);
83108302
error=0;

sql/sql_plugin_services.ic

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ static struct wsrep_service_st wsrep_handler = {
181181
wsrep_trx_is_aborting,
182182
wsrep_trx_order_before,
183183
wsrep_unlock_rollback,
184-
wsrep_set_data_home_dir,
185-
wsrep_thd_is_applier,
184+
wsrep_set_data_home_dir
186185
};
187186

188187
static struct thd_specifics_service_st thd_specifics_handler=

sql/wsrep_dummy.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
my_bool wsrep_thd_is_BF(THD *, my_bool)
2121
{ return 0; }
2222

23-
my_bool wsrep_thd_is_applier(THD *)
24-
{ return 0; }
25-
2623
int wsrep_trx_order_before(THD *, THD *)
2724
{ return 0; }
2825

sql/wsrep_mysqld.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,6 +2470,7 @@ extern "C" void wsrep_thd_set_exec_mode(THD *thd, enum wsrep_exec_mode mode)
24702470
thd->wsrep_exec_mode= mode;
24712471
}
24722472

2473+
24732474
extern "C" void wsrep_thd_set_query_state(
24742475
THD *thd, enum wsrep_query_state state)
24752476
{

sql/wsrep_thd.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -596,15 +596,6 @@ my_bool wsrep_thd_is_BF(THD *thd, my_bool sync)
596596
return status;
597597
}
598598

599-
my_bool wsrep_thd_is_applier(THD *thd)
600-
{
601-
my_bool ret = FALSE;
602-
if (thd) {
603-
ret = thd->wsrep_applier;
604-
}
605-
return ret;
606-
}
607-
608599
extern "C"
609600
my_bool wsrep_thd_is_BF_or_commit(void *thd_ptr, my_bool sync)
610601
{

sql/wsrep_thd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ int wsrep_abort_thd(void *bf_thd_ptr, void *victim_thd_ptr,
3737
*/
3838
extern void wsrep_thd_set_PA_safe(void *thd_ptr, my_bool safe);
3939
extern my_bool wsrep_thd_is_BF(THD *thd, my_bool sync);
40-
extern my_bool wsrep_thd_is_applier(THD *thd);
4140
extern my_bool wsrep_thd_is_wsrep(void *thd_ptr);
4241

4342
enum wsrep_conflict_state wsrep_thd_conflict_state(void *thd_ptr, my_bool sync);
@@ -48,7 +47,6 @@ extern "C" int wsrep_thd_in_locking_session(void *thd_ptr);
4847
#else /* WITH_WSREP */
4948

5049
#define wsrep_thd_is_BF(T, S) (0)
51-
#define wsrep_thd_is_applier(T) (0)
5250
#define wsrep_abort_thd(X,Y,Z) do { } while(0)
5351
#define wsrep_create_appliers(T) do { } while(0)
5452

0 commit comments

Comments
 (0)