Skip to content

Instantly share code, notes, and snippets.

@dawn360
Last active November 6, 2018 14:09
Show Gist options
  • Save dawn360/599f933db36c86f328f47c926acd0683 to your computer and use it in GitHub Desktop.
Save dawn360/599f933db36c86f328f47c926acd0683 to your computer and use it in GitHub Desktop.
MySQL Transaction Locks
select * from INFORMATION_SCHEMA.INNODB_TRX;
select * from INFORMATION_SCHEMA.INNODB_LOCKS;
SELECT CONCAT('KILL ', trx.trx_mysql_thread_id) kill_statement, trx.trx_mysql_thread_id thd_id, ps.user, ps.host, trx.trx_query FROM INFORMATION_SCHEMA.INNODB_TRX trx JOIN INFORMATION_SCHEMA.PROCESSLIST ps ON trx.trx_mysql_thread_id = ps.id WHERE user != 'system_user';
KILL 17333;
-- http://www.markleith.co.uk/2011/05/31/finding-and-killing-long-running-innodb-transactions-with-events/
ALTER EVENT kill_long_transactions DISABLE;
ALTER EVENT kill_long_transactions ENABLE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment