[PATCH] MDEV-23915 ER_KILL_DENIED_ERROR not passed a thread id
authorDaniel Black <daniel@mariadb.org>
Tue, 22 Feb 2022 23:10:01 +0000 (10:10 +1100)
committerOtto Kekäläinen <otto@debian.org>
Thu, 10 Mar 2022 06:26:32 +0000 (06:26 +0000)
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.

Gbp-Pq: Name 2028-MDEV-23915-fix-test-main.grat_kill.patch

mysql-test/suite/galera/r/galera_kill_applier.result
mysql-test/suite/galera/t/galera_kill_applier.test
sql/sql_parse.cc

index 78a91d2638f5697a0aed9c0139e5b52b86ba7183..a47f486b5fb6289c4aca01e5ada00a79459deca2 100644 (file)
@@ -5,9 +5,13 @@ SELECT @@wsrep_slave_threads;
 @@wsrep_slave_threads
 1
 SET GLOBAL wsrep_slave_threads=2;
+KILL ID;
 Got one of the listed errors
+KILL QUERY ID;
 Got one of the listed errors
+KILL ID;
 Got one of the listed errors
+KILL QUERY ID;
 Got one of the listed errors
 SET GLOBAL wsrep_slave_threads=DEFAULT;
 connection node_1;
index 3a285822613867fb08e4b4164c16d43ece2e3e60..88ec55ed0c175d530d5c1de220a77d61db9dd570 100644 (file)
@@ -16,21 +16,23 @@ SET GLOBAL wsrep_slave_threads=2;
 
 --let $applier_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle' LIMIT 1`
 
---disable_query_log
+--replace_result $applier_thread ID
 --error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
 --eval KILL $applier_thread
 
+--replace_result $applier_thread ID
 --error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
 --eval KILL QUERY $applier_thread
 
 --let $aborter_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep aborter idle' LIMIT 1`
 
+--replace_result $aborter_thread ID
 --error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
 --eval KILL $aborter_thread
 
+--replace_result $aborter_thread ID
 --error ER_KILL_DENIED_ERROR,ER_KILL_DENIED_ERROR
 --eval KILL QUERY $aborter_thread
---enable_query_log
 
 SET GLOBAL wsrep_slave_threads=DEFAULT;
 
index 0886fc85151886d11a60f74fa51b110b12a34f2a..5d0847c955d5c9c6fef49dc2bfee683f8fe80782 100644 (file)
@@ -9393,15 +9393,18 @@ sql_kill_user(THD *thd, LEX_USER *user, killed_state state)
 {
   uint error;
   ha_rows rows;
-  if (likely(!(error= kill_threads_for_user(thd, user, state, &rows))))
-    my_ok(thd, rows);
-  else
+
+  switch (error= kill_threads_for_user(thd, user, state, &rows))
   {
-    /*
-      This is probably ER_OUT_OF_RESOURCES, but in the future we may
-      want to write the name of the user we tried to kill
-    */
-    my_error(error, MYF(0), user->host.str, user->user.str);
+  case 0:
+    my_ok(thd, rows);
+    break;
+  case ER_KILL_DENIED_ERROR:
+    my_error(error, MYF(0), (unsigned long) thd->thread_id);
+    break;
+  case ER_OUT_OF_RESOURCES:
+  default:
+    my_error(error, MYF(0));
   }
 }