今天在处理慢查询平台的slow query时发现今天排在第一个的居然是一个简单的SQL,运行了4166次,最长耗时610秒,长期处于“Waiting for table flush”状态。
结果说在前面
排查一番后果然不出意外:一个慢查询堵塞数据库备份进程,备份进程堵塞了后续的查询SQL,最后导致后续的大面积SQL等待。
那么问题来了
- 一个慢查询是怎么堵塞mysqldump进程
- mysqldump是怎么堵塞后续的查询请求
首先我们来看下“Waiting for table flush”的解释
Waiting for table:
Waiting for tables, Waiting for table, Waiting for table
flush
The thread got a notification that the underlying structure for a
table has changed and it needs to reopen the table to get the new
structure. However, to reopen the table, it must wait until all
other threads have …