Skip to content

Commit 99837c6

Browse files
committed
MDEV-23915 ER_KILL_DENIED_ERROR not passed a thread id
The 10.5 test error main.grant_kill showed up a incorrect thread id on a big endian architecture. The cause of this is the sql_kill_user function assumed the error was ER_OUT_OF_RESOURCES, when the the actual error was ER_KILL_DENIED_ERROR. ER_KILL_DENIED_ERROR as an error message requires a thread id to be passed as unsigned long, however a user/host was passed. ER_OUT_OF_RESOURCES doesn't even take a user/host, despite the optimistic comment. We remove this being passed as an argument to the function so that when MDEV-21978 is implemented one less compiler format warning is generated (which would have caught this error sooner). Thanks Otto for reporting and Marko for analysis.
1 parent 03c3dc6 commit 99837c6

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
connection node_2;
22
SET GLOBAL wsrep_slave_threads=2;
3+
KILL ID;
34
Got one of the listed errors
5+
KILL QUERY ID;
46
Got one of the listed errors
7+
KILL ID;
58
Got one of the listed errors
9+
KILL QUERY ID;
610
Got one of the listed errors
711
SET GLOBAL wsrep_slave_threads=1;
812
connection node_1;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,23 @@ SET GLOBAL wsrep_slave_threads=2;
1515

1616
--let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle' LIMIT 1`
1717

18-
--disable_query_log
18+
--replace_result $applier_thread ID
1919
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
2020
--eval KILL $applier_thread
2121

22+
--replace_result $applier_thread ID
2223
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
2324
--eval KILL QUERY $applier_thread
2425

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

28+
--replace_result $aborter_thread ID
2729
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
2830
--eval KILL $aborter_thread
2931

32+
--replace_result $aborter_thread ID
3033
--error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
3134
--eval KILL QUERY $aborter_thread
32-
--enable_query_log
3335

3436
SET GLOBAL wsrep_slave_threads=1;
3537

sql/sql_parse.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9117,15 +9117,17 @@ void sql_kill_user(THD *thd, LEX_USER *user, killed_state state)
91179117
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
91189118
}
91199119
#endif /* WITH_WSREP */
9120-
if (!(error= kill_threads_for_user(thd, user, state, &rows)))
9121-
my_ok(thd, rows);
9122-
else
9120+
switch (error= kill_threads_for_user(thd, user, state, &rows))
91239121
{
9124-
/*
9125-
This is probably ER_OUT_OF_RESOURCES, but in the future we may
9126-
want to write the name of the user we tried to kill
9127-
*/
9128-
my_error(error, MYF(0), user->host.str, user->user.str);
9122+
case 0:
9123+
my_ok(thd, rows);
9124+
break;
9125+
case ER_KILL_DENIED_ERROR:
9126+
my_error(error, MYF(0), (unsigned long) thd->thread_id);
9127+
break;
9128+
case ER_OUT_OF_RESOURCES:
9129+
default:
9130+
my_error(error, MYF(0));
91299131
}
91309132
#ifdef WITH_WSREP
91319133
return;

0 commit comments

Comments
 (0)