Skip to main content

Kill MySQL Query in AWS (Tickler)

The Problem

Sometimes we encounter a "Zombie Query" in databases. This may be a deadlocked process or a long-running job whose front-end hit its timeout. Especially in the latter case, the query is chewing up server resources for no purpose. Ad hoc reports built on a poorly indexed data source is a common enough example.

MySQL Workbench has a nice, interactive Admin UI for identifying these processes and terminating them.

Alas, since we migrated our DB server to AWS RDS database service, the Workbench admin tool no longer does the job of killing the zombie query.

The AWS Solution

To kill the zombie query in AWS RDS service, we need the process id, and we need to put that into a custom procedure.



SHOW PROCESSLIST;

-- Get the process number from the ID column

CALL mysql.rds_kill_query(1234567);


These "memory tickler" posts are quick-hits to refresh my mind about little technical details that arise infrequently enough that I forget in between, and wind up doing an internet search every time. By posting them here, they will be easier to find as needed.)