Mysql 死锁查询和解决

查看死锁的事务

SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX;

杀死线程用kill方法杀的是trx_mysql_thread_id的值,如果trx_mysql_thread_id是3321,那就是
kill 3321 即可

查看死锁进程

SHOW PROCESSLIST

列表中会有ID值杀死进程只要kill对应的id即可,比如id是2311,那就直接执行 kill 2311 即可

详细学习:https://www.cnblogs.com/likui360/p/5856114.html

补充针对一些奇葩的锁

select a.SQL_TEXT,c.id,d.trx_started from `performance_schema`.events_statements_current a join `performance_schema`.threads b on a.THREAD_ID=b.THREAD_ID join information_schema.processlist c on b.PROCESSLIST_ID=c.id join information_schema.innodb_trx d on c.id=d.trx_mysql_thread_id order by d.trx_started

发表评论

邮箱地址不会被公开。 必填项已用*标注