mysql waiting for table flush_Waiting for table flush 阻塞查询的问题

1、此状态表示大量thread正在等待慢查询语句执行完成。

原因:

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 阻塞,致使后续查询收到表变更通知,需要等待重新打开表。

即使这个时候停止flush tables操作也不会马上恢复,这些大量的Waiting for table flush 线程会等到之前的慢查询终止才会执行。

2、易引发这种情况的操作

慢查询+FLUSH TABLES tbl_name, ALTER TABLE, RENAME TABLE, REPAIR TABLE, ANALYZE TABLE, orOPTIMIZE TABLE  这些操作。

例如:比如在mysqldump、innobackupex进行备份时就很有可能引发这种情况。

3、解决方案

找出慢查询kill掉,并进行SQL优化防止再次引发。

4、预防措施

在业务高峰期不要对数据库进行FLUSH TABLES tbl_name, ALTER TABLE, RENAME TABLE, REPAIR TABLE, ANALYZE TABLE, orOPTIMIZE TABLE 这些操作。

备份、DDL语句等操作尽量避开业务高峰。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值