MDL 现场
MDL 现场
SELECT * FROM performance_schema.metadata_locks
WHERE OBJECT_SCHEMA='appdb'\G
-- 找 PENDING 的 DDL 与 GRANTED 的长事务
SELECT trx_id, trx_state, trx_started, trx_mysql_thread_id
FROM information_schema.INNODB_TRX ORDER BY trx_started LIMIT 5;| 源头 | 未提交事务(含只读)、长查询、备份工具持锁 |
|---|---|
| 现象 | DDL 卡住、后续查询排队、连接数飙升 |
| 处置 | 找到源头事务确认后 KILL;DDL 避开业务高峰 |
lock_wait_timeout(默认 31536000 秒=1 年)不对 DDL 生效:MDL 等待可能超出预期时长。