Skip to content

Commit 1001dae

Browse files
janlindstromsysprg
authored andcommitted
MDEV-12008 : Change error code for Galera unkillable threads
Changed error code for Galera unkillable threads to be ER_KILL_DENIED_HIGH_PRIORITY giving message This is a high priority thread/query and cannot be killed without the compromising consistency of the cluster also a warning is produced Thread %lld is [wsrep applier|high priority] and cannot be killed Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
1 parent cfa6143 commit 1001dae

File tree

6 files changed

+91
-15
lines changed

6 files changed

+91
-15
lines changed

mysql-test/suite/galera/r/galera_kill_applier.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ SELECT @@wsrep_slave_threads;
66
1
77
SET GLOBAL wsrep_slave_threads=2;
88
KILL ID;
9-
Got one of the listed errors
9+
ERROR HY000: This is a high-priority thread/query and cannot be killed without compromising the consistency of the cluster
1010
KILL QUERY ID;
11-
Got one of the listed errors
11+
ERROR HY000: This is a high-priority thread/query and cannot be killed without compromising the consistency of the cluster
1212
KILL ID;
13-
Got one of the listed errors
13+
ERROR HY000: This is a high-priority thread/query and cannot be killed without compromising the consistency of the cluster
1414
KILL QUERY ID;
15-
Got one of the listed errors
15+
ERROR HY000: This is a high-priority thread/query and cannot be killed without compromising the consistency of the cluster
1616
SET GLOBAL wsrep_slave_threads=DEFAULT;
1717
connection node_1;
1818
create table t1(a int not null primary key) engine=innodb;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
connection node_2;
2+
connection node_1;
3+
connect con1,127.0.0.1,root,,test,$NODE_MYPORT_1;
4+
call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
5+
CREATE TABLE t1(c1 INT PRIMARY KEY, c2 INT) ENGINE=InnoDB;
6+
INSERT into t1 values (1,1);
7+
SET DEBUG_SYNC = 'alter_table_after_open_tables SIGNAL bf_started WAIT_FOR bf_continue';
8+
ALTER TABLE t1 DROP COLUMN c2;;
9+
connection node_1;
10+
SET SESSION wsrep_sync_wait = 0;
11+
SET DEBUG_SYNC = 'now WAIT_FOR bf_started';
12+
KILL ID;
13+
ERROR HY000: This is a high-priority thread/query and cannot be killed without compromising the consistency of the cluster
14+
KILL QUERY ID;
15+
ERROR HY000: This is a high-priority thread/query and cannot be killed without compromising the consistency of the cluster
16+
connection node_1;
17+
SET DEBUG_SYNC = 'now SIGNAL bf_continue';
18+
connection con1;
19+
SET DEBUG_SYNC = 'RESET';
20+
SELECT * FROM t1;
21+
c1
22+
1
23+
connection node_1;
24+
DROP TABLE t1;
25+
disconnect con1;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ SET GLOBAL wsrep_slave_threads=2;
1717
--let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle' LIMIT 1`
1818

1919
--replace_result $applier_thread ID
20-
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
20+
--error ER_KILL_DENIED_HIGH_PRIORITY
2121
--eval KILL $applier_thread
2222

2323
--replace_result $applier_thread ID
24-
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
24+
--error ER_KILL_DENIED_HIGH_PRIORITY
2525
--eval KILL QUERY $applier_thread
2626

2727
--let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
2828

2929
--replace_result $aborter_thread ID
30-
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
30+
--error ER_KILL_DENIED_HIGH_PRIORITY
3131
--eval KILL $aborter_thread
3232

3333
--replace_result $aborter_thread ID
34-
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
34+
--error ER_KILL_DENIED_HIGH_PRIORITY
3535
--eval KILL QUERY $aborter_thread
3636

3737
SET GLOBAL wsrep_slave_threads=DEFAULT;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--source include/galera_cluster.inc
2+
--source include/have_debug_sync.inc
3+
--source include/have_debug.inc
4+
5+
--connect con1,127.0.0.1,root,,test,$NODE_MYPORT_1
6+
7+
call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
8+
9+
CREATE TABLE t1(c1 INT PRIMARY KEY, c2 INT) ENGINE=InnoDB;
10+
INSERT into t1 values (1,1);
11+
12+
SET DEBUG_SYNC = 'alter_table_after_open_tables SIGNAL bf_started WAIT_FOR bf_continue';
13+
--send ALTER TABLE t1 DROP COLUMN c2;
14+
15+
--connection node_1
16+
SET SESSION wsrep_sync_wait = 0;
17+
SET DEBUG_SYNC = 'now WAIT_FOR bf_started';
18+
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'debug sync point: alter_table_after_open_tables'
19+
--source include/wait_condition.inc
20+
21+
--let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'debug sync point:%' LIMIT 1`
22+
23+
--replace_result $applier_thread ID
24+
--error ER_KILL_DENIED_HIGH_PRIORITY
25+
--eval KILL $applier_thread
26+
27+
--replace_result $applier_thread ID
28+
--error ER_KILL_DENIED_HIGH_PRIORITY
29+
--eval KILL QUERY $applier_thread
30+
31+
--connection node_1
32+
SET DEBUG_SYNC = 'now SIGNAL bf_continue';
33+
34+
--connection con1
35+
--reap
36+
SET DEBUG_SYNC = 'RESET';
37+
SELECT * FROM t1;
38+
39+
--connection node_1
40+
DROP TABLE t1;
41+
--disconnect con1

sql/share/errmsg-utf8.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9111,3 +9111,5 @@ ER_NOT_ALLOWED_IN_THIS_CONTEXT
91119111
eng "'%-.128s' is not allowed in this context"
91129112
ER_DATA_WAS_COMMITED_UNDER_ROLLBACK
91139113
eng "Engine %s does not support rollback. Changes were committed during rollback call"
9114+
ER_KILL_DENIED_HIGH_PRIORITY
9115+
eng "This is a high-priority thread/query and cannot be killed without compromising the consistency of the cluster"

sql/sql_parse.cc

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9415,17 +9415,21 @@ kill_one_thread(THD *thd, my_thread_id id, killed_state kill_signal, killed_type
94159415

94169416
mysql_mutex_lock(&tmp->LOCK_thd_data); // Lock from concurrent usage
94179417

9418-
#ifdef WITH_WSREP
9419-
if (((thd->security_ctx->master_access & PRIV_KILL_OTHER_USER_PROCESS) ||
9420-
thd->security_ctx->user_matches(tmp->security_ctx)) &&
9421-
!wsrep_thd_is_BF(tmp, false) && !tmp->wsrep_applier)
9422-
#else
94239418
if ((thd->security_ctx->master_access & PRIV_KILL_OTHER_USER_PROCESS) ||
94249419
thd->security_ctx->user_matches(tmp->security_ctx))
9425-
#endif /* WITH_WSREP */
94269420
{
9427-
{
94289421
#ifdef WITH_WSREP
9422+
if (wsrep_thd_is_BF(tmp, false) || tmp->wsrep_applier)
9423+
{
9424+
error= ER_KILL_DENIED_HIGH_PRIORITY;
9425+
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
9426+
ER_KILL_DENIED_HIGH_PRIORITY,
9427+
"Thread %lld is %s and cannot be killed",
9428+
tmp->thread_id,
9429+
(tmp->wsrep_applier ? "wsrep applier" : "high priority"));
9430+
}
9431+
else
9432+
{
94299433
if (WSREP(tmp))
94309434
{
94319435
/* Object tmp is not guaranteed to exist after wsrep_kill_thd()
@@ -9435,7 +9439,9 @@ kill_one_thread(THD *thd, my_thread_id id, killed_state kill_signal, killed_type
94359439
#endif /* WITH_WSREP */
94369440
tmp->awake_no_mutex(kill_signal);
94379441
error= 0;
9442+
#ifdef WITH_WSREP
94389443
}
9444+
#endif /* WITH_WSREP */
94399445
}
94409446
else
94419447
error= (type == KILL_TYPE_QUERY ? ER_KILL_QUERY_DENIED_ERROR :
@@ -9565,7 +9571,9 @@ void sql_kill(THD *thd, my_thread_id id, killed_state state, killed_type type)
95659571
thd->send_kill_message();
95669572
}
95679573
else
9574+
{
95689575
my_error(error, MYF(0), id);
9576+
}
95699577
}
95709578

95719579

0 commit comments

Comments
 (0)