zoukankan      html  css  js  c++  java
  • 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语句等操作尽量避开业务高峰。

    复制来源:https://blog.csdn.net/donghaixiaolongwang/article/details/76099697

  • 相关阅读:
    QBoxLayout中setSpacing(int)和addSpacing(int)的区别
    BZOJ1017 树形DP
    树形DP 2415HDU
    树形DP基础题 HDU1520
    最小生成树个数 并查集压缩路径
    伸展树基本概念基本题目
    BZOJ1010单调性DP优化
    BZOJ1009 矩阵快速幂+DP+KMP
    字典树(数组实现)
    poj 1611 The Suspects(并查集输出集合个数)
  • 原文地址:https://www.cnblogs.com/EikiXu/p/11014552.html
Copyright © 2011-2022 走看看