07 03 2023

看这些办法

1. 查看当前存在的事务。                              
 select * from information_schema.INNODB_TRX\G;         

2.查看当前事务执行时间,如果某个事务执行了很长时间,可能就是有问题的那个。                          
select id, time from information_schema.PROCESSLIST where id in (select trx_mysql_thread_id from information_schema.INNODB_TRX )    

3.查看当前事务正在执行的语句。
#我们可以借助performance_schema.events_statements_current,该表可以看到会话对应的sql。

SELECT b.processlist_id, c.db, a.sql_text, c.command, c.time, c.state FROM performance_schema.events_statements_current a JOIN performance_schema.threads b USING(thread_id) JOIN information_schema.processlist c ON b.processlist_id = c.id WHERE a.sql_text NOT LIKE '%performance%';


4.kill trx_mysql_thread_id;

发表评论