aws,

How to kill thread or query in AWS RDS

Mar 24, 2022 · 1 min read · Post a comment

Stopping some threads or queries that may appear in the deadlock queue or locked from the InnoDB engine on AWS RDS is a different thing than self-hosted MySQL or MariaDB. They can potentially increase the database CPU load and cause a lot of problems. If you spot that some transactions are being stuck and they are reaching the max execution time, then you may need to kill the thread or the query itself.

Prerequisites

  • AWS account
  • AWS RDS

Solution

Step 1. To get useful information about the DB status, run:

show engine innodb status;

Step 2. To kill some stuck threads on AWS RDS, run:

CALL mysql.rds_kill(ThreadID)

Step 3. Killing some queries on AWS RDS can be done with:

CALL mysql.rds_kill_query(ThreadID) 

Conclusion

Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.