-- mysql
show full PROCESSLIST;
-- 查看哪些表在锁。
show open tables where IN_use>0;
-- 正在执行的事务:
SELECT * FROM information_schema.INNODB_TRX;
-- 8.0之前 查看正在锁的事务
select * from information_schema.innodb_locks;
-- 查看等待锁的事务
-- 8.0之前
select * from information_schema.innodb_lock_waits;
-- 8.0之后
select * from sys.innodb_lock_waits;
SHOW STATUS LIKE 'INNODB_ROW_LOCK_%';
SHOW ENGINE INNODB STATUS;
SELECT VERSION();
-- 通过连接线程ID找SQL线程语句
select * from performance_schema.threads;
-- 通过SQL线程找到SQL语句
select * from performance_schema.events_statements_history;
mysql事务锁排查
于 2024-05-07 11:04:44 首次发布