如何在没有开启ps.metadata_locks快速判断哪个会话持有FTWRL锁
本帖最后由 bedrock 于 2022-10-31 11:54 编辑本地实验
版本:5.7.38
已被锁,假设有几千个会话,未开启ps.metadata_locks,如何快速定位持有FTWRL语句id
注:ps.metadata_locks 默认是被关闭的,当数据库已经被 FTWRL 时
开启语句:UPDATE performance_schema.setup_instruments SET ENABLED = 'YES' WHERE NAME ='wait/lock/metadata/sql/mdl'; 也会被阻塞
会话一
mysql> flush tables with read lock;
Query OK, 0 rows affected (0.00 sec)
会话2,被阻塞
mysql> delete from test.limit_test where id=100001;
会话1
mysql> show full processlist\G
*************************** 1. row ***************************
Id: 1
User: event_scheduler
Host: localhost
db: NULL
Command: Daemon
Time: 331949
State: Waiting on empty queue
Info: NULL
*************************** 2. row ***************************
Id: 38
User: root
Host: localhost
db: test
Command: Query
Time: 0
State: starting
Info: show full processlist
*************************** 3. row ***************************
Id: 39
User: canal
Host: alltest:33512
db: canal_manager
Command: Sleep
Time: 35
State:
Info: NULL
*************************** 4. row ***************************
Id: 40
User: root
Host: localhost
db: NULL
Command: Query
Time: 5
State: Waiting for global read lock
Info: delete from test.limit_test where id=100001
4 rows in set (0.00 sec)
现场的SHOW PROCESSLIST发一下 yejr 发表于 2022-10-31 11:43
现场的SHOW PROCESSLIST发一下
叶老师,这个是我自己本地的实验,为了模拟下生产上假如发生这种情况怎么处理,几千个会话是假设的 yejr 发表于 2022-10-31 11:43
现场的SHOW PROCESSLIST发一下
补充在正文了 bedrock 发表于 2022-10-31 11:51
补充在正文了
并没看到开启语句被阻塞啊
页:
[1]