一、此状态表示大量thread正在等待慢查询语句执行完成。mysql
缘由:sql
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 closed the table in question.
This notification takes place if another thread has used FLUSH TABLES
or one of the following statements on the table in question:
FLUSH TABLES tbl_name, ALTER TABLE, RENAME TABLE, REPAIR TABLE, ANALYZE TABLE, orOPTIMIZE TABLE.数据库
翻译优化
主要是由于有慢查询正在进行的时候 ,执行了相似于flush tables的操做。致使flush tables 阻塞,导致后续查询收到表变动通知,须要等待从新打开表。.net
即便这个时候中止flush tables操做也不会立刻恢复,这些大量的Waiting for table flush 线程会等到以前的慢查询终止才会执行。线程
二、易引起这种状况的操做翻译
慢查询+FLUSH TABLES tbl_name, ALTER TABLE, RENAME TABLE, REPAIR TABLE, ANALYZE TABLE, orOPTIMIZE TABLE 这些操做。blog
例如:好比在mysqldump、innobackupex进行备份时就颇有可能引起这种状况。get
三、解决方案it
找出慢查询kill掉,并进行SQL优化防止再次引起。
四、预防措施
在业务高峰期不要对数据库进行FLUSH TABLES tbl_name, ALTER TABLE, RENAME TABLE, REPAIR TABLE, ANALYZE TABLE, orOPTIMIZE TABLE 这些操做。
备份、DDL语句等操做尽可能避开业务高峰。
复制来源:https://blog.csdn.net/donghaixiaolongwang/article/details/76099697