排查锁及事务相关:
show status like 'innodb_row_lock%'; -- 查看所有锁状态
select * from information_schema.INNODB_LOCKS; -- 查看锁
select * from information_schema.INNODB_LOCK_WAITS; -- 查询锁等待
select * from information_schema.INNODB_TRX; -- 查看事务
show engine innodb status; -- 查看innodb状态
show variables like 'autocommit'; -- 查看当前会话是否自动提交事务;
show PROCESSLIST; 或者 select * from information_schema.processlist; -- 查询正在运行的线程
show variables like "Innodb_lock_wait_timeout" -- 查看当前会话锁等待超时时间限制,默认为50S;
set Innodb_lock_wait_timeout = 5; -- 设置当前会话锁等待超时时间为5S;
set autocommit = 0 ; -- 设置当前会话为非自动提交事务 0:非自动提交事务,对应 OFF 1:自动提交事务,对应为 ON