Skip to content

Instantly share code, notes, and snippets.

@arliber
Last active December 1, 2020 13:12
Show Gist options
  • Save arliber/8cc701b8667dcfd5ecdc20cd0004d01c to your computer and use it in GitHub Desktop.
Save arliber/8cc701b8667dcfd5ecdc20cd0004d01c to your computer and use it in GitHub Desktop.
Debug MySQL for stuck sessions and transctions
# Run this first
USE INFORMATION_SCHEMA;
# Check the transactions section in:
SHOW ENGINE INNODB STATUS;
# To check about all the locks transactions are waiting for:
SELECT * FROM INNODB_LOCK_WAITS;
# A list of blocking transactions:
SELECT INNODB_LOCKS.*
FROM INNODB_LOCKS
JOIN INNODB_LOCK_WAITS
ON (INNODB_LOCKS.LOCK_TRX_ID = INNODB_LOCK_WAITS.BLOCKING_TRX_ID);
# A list of transactions waiting for locks:
SELECT TRX_ID, TRX_REQUESTED_LOCK_ID, TRX_MYSQL_THREAD_ID, TRX_QUERY
FROM INNODB_TRX
WHERE TRX_STATE = 'LOCK WAIT';
# Kill a process in RDS
CALL mysql.rds_kill(<process id>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment