AWS: MariaDB RDS – kill: You are not owner of thread

By | 05/14/2019
 

We have AWS RDS with MariaDB.

The error below and its solution aren’t specific to AWS RDS and MariaDB.

The next error appears during attempt to kill() a thread in MySQL:

[simterm]

MariaDB [(none)]> kill 759;
ERROR 1095 (HY000): You are not owner of thread 759

[/simterm]

The solution is to use the mysql.rds_kill() procedure instead:

[simterm]

MariaDB [(none)]> SHOW CREATE PROCEDURE mysql.rds_kill\G
*************************** 1. row ***************************
           Procedure: rds_kill
            sql_mode: NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
    Create Procedure: CREATE DEFINER=`rdsadmin`@`localhost` PROCEDURE `rds_kill`(IN thread BIGINT)
    READS SQL DATA
    DETERMINISTIC
BEGIN
  DECLARE l_user varchar(16);
  DECLARE l_host varchar(64);
  DECLARE foo varchar(255);

  SELECT user, host INTO l_user, l_host
  FROM information_schema.processlist
  WHERE id = thread;

  IF l_user = "rdsadmin" and l_host like "localhost%" THEN
    select `ERROR (RDS): CANNOT KILL RDSADMIN SESSION` into foo;
  ELSEIF l_user = "rdsrepladmin" THEN
    select `ERROR (RDS): CANNOT KILL RDSREPLADMIN SESSION` into foo;
  ELSE
    KILL thread;
  END IF;
END

[/simterm]

Execute it:

[simterm]

MariaDB [(none)]> CALL mysql.rds_kill(761);
Query OK, 0 rows affected (0.00 sec)

[/simterm]

For Azure MySQL, there is a similar procedure mysql.az_kill().

Done.