mysql 查看当前正在被锁定的事务和等待锁的事务信息
SELECT
r.trx_id AS '事务ID',
r.trx_state AS '事务状态',
r.trx_started AS '事务开始时间',
r.trx_wait_started AS '等待开始时间',
l.lock_table AS '表',
l.lock_index AS '索引',
l.lock_mode AS '锁模式',
r.trx_mysql_thread_id AS '线程ID'
FROM
information_schema.innodb_trx r
INNER JOIN information_schema.innodb_locks l ON r.trx_id = l.lock_trx_id
WHERE
r.trx_state != 'IDLE'
ORDER BY
r.trx_started;