MySQL锁

2023-04-17  本文已影响0人  古飞_数据

1.查看是否有锁的等待
show status like '%innodb_rows_lock%'
当前的current
所有的

begin; --1
update city set countrycode="CHN" where id=100;  --1
begin; --2
update city set countrycode="USA" where id=100;  --2
show status like '%innodb_rows_lock%'  --3

2.查看等待锁和锁源的信息

select * from sys.innodb_lock_waits;   获取锁源 找到blocking_pid

3.通过锁源的pid找到执行SQL的thread_id

select * from performance_schema_schema.threads where processlist_id= xx;   找到thread_id

找到上面查出来的thread_id,查看具有的语句
4.通过thread_id找到具体的锁源语句

select * from performance_schema.events_statements_current where thread_id=xx;   
select * from performance_schema.events_statements_history where thread_id=xx;
上一篇 下一篇

猜你喜欢

热点阅读