热点
深度学习驱动点评闭环:UI测试创业路,reasoning_content:我们要求以UI测试工程师的口吻,写一个与技术、科技相关,关于[深度学习驱动点评闭环:创业成功的创新路径]的标题需要简短精炼,字数30字以内直接输出标题,不要加说明nn思考:UI测试工程师的口吻,可以突出测试、质量、用户体验等角度结合深度学习驱动点评闭环:创业成功的创新路径,核心是深度学习技术驱动用户点评的闭环,从而帮助创业成功可以写成类似UI测试视角:深度学习闭环驱动创业成功或深度学习点评闭环:UI测试工程师的技术创业路径等但要注意字数尝试几个:nn- 深度学习闭环,UI测试赋能创业成功(13字)n- UI测试工程师:深度学习驱动点评闭环创业(16字)n- 深度学习+点评闭环:UI测试的创业创新(15字)n- 用深度学习闭环点评,UI测试驱动创业(14字)n- UI测试视角:深度学习闭环点评创业路径(16字)nn最简洁且符合要求:可能需要包含深度学习驱动点评闭环这个核心短语例如:深度学习驱动点评闭环:UI测试创业路径(16字)或者更精炼:深度学习闭环点评,UI测试创业(12字)但少了驱动nn确保直接输出我选一个:深度学习驱动点评闭环:UI测试创业创新路径(17字)但创新路径有点重复或者:深度学习闭环点评:UI测试技术创业路(16字)最终输出一个
15 9 月 2026, 周二

Mysql从库大量select堵塞处于Waitingfortableflush状态该怎么办

本篇文章给大家分享的是有关Mysql从库大量select堵塞处于Waiting for table flush 状态该怎么办,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
 Mysql从库大量select堵塞处于Waitingfortableflush状态该怎么办
背景:
mycat读写分离,应用大量select超时
1.检查
通过检查发现大量select处于Waiting for table flush 状态,仔细看了一下processlist以及时间段,可以断定是备份加select慢查询引起的!
2.重现环境
session1
session2
查看此时的processlist状态
 
mysql> show full processlist;
+------+------+---------------------+--------+-------------+---------+-----------------------------------------------------------------------+---------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+------+------+---------------------+--------+-------------+---------+-----------------------------------------------------------------------+---------------------------------------------------+
| 2 | repl | 47.93.243.162:43700 | NULL | Binlog Dump | 1527333 | Master has sent all binlog to slave; waiting for binlog to be updated | NULL |
| 9140 | root | localhost | devops | Query | 564 | User sleep | select *,sleep(1000) from operation_log limit 100 |
| 9141 | root | localhost | NULL | Query | 0 | init | show full processlist |
| 9143 | root | localhost:56880 | NULL | Query | 509 | Waiting for table flush | FLUSH NO_WRITE_TO_BINLOG TABLES |
终端二执行xtracebackup备份
。。。。。
。。。。。
>> log scanned up to (768745274)
。。。。。备份堵塞
终端一执行一个慢查询
mysql> select *,sleep(1000) from operation_log limit 100
session3
 
终端3对慢查询涉及到的表进行查询操作
[root@iZ2ze66bhrbxkc31nljgjnZ ~]# mysql -uroot -p***** -e "select * from operation_log limit 10" devops
Warning: Using a password on the command line interface can be insecure.
...堵塞状态
此时的processlist状态
 
mysql> show full processlist;
+------+------+---------------------+--------+-------------+---------+-----------------------------------------------------------------------+---------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+------+------+---------------------+--------+-------------+---------+-----------------------------------------------------------------------+---------------------------------------------------+
| 2 | repl | 47.93.243.162:43700 | NULL | Binlog Dump | 1527460 | Master has sent all binlog to slave; waiting for binlog to be updated | NULL |
| 9140 | root | localhost | devops | Query | 691 | User sleep | select *,sleep(1000) from operation_log limit 100 |
| 9141 | root | localhost | NULL | Query | 0 | init | show full processlist |
| 9143 | root | localhost:56880 | NULL | Query | 636 | Waiting for table flush | FLUSH NO_WRITE_TO_BINLOG TABLES |
| 9150 | root | localhost | devops | Query | 454 | Waiting for table flush | select * from operation_log limit 10 | --查询被堵塞
+------+------+---------------------+--------+-------------+---------+-----------------------------------------------------------------------+---------------------------------------------------+
步骤1阻塞了步骤二,步骤二导致步骤三需要等待步骤一。
session4
 
终端四对其它非慢查询中的表进行查询(不堵塞)
[root@iZ2ze66bhrbxkc31nljgjnZ ~]# mysql -uroot -pESBecs00 -e "select * from role limit 10" devops
Warning: Using a password on the command line interface can be insecure.
+----+-----------------+--------------------------------+--------+
| id | role_name | description | status |
+----+-----------------+--------------------------------+--------+
| 1 | 超级管理员 | 所有权限 | 1 |
| 3 | 开发工程师 | 开发工程师开发工程师 | 1 |
| 4 | 运维工程师 | 运帷工程师运帷工程师 | 1 |
+----+-----------------+--------------------------------+--------+
[root@iZ2ze66bhrbxkc31nljgjnZ ~]# mysql -uroot -pESBecs00 -e "select * from module limit 10" devops
Warning: Using a password on the command line interface can be insecure.
+-----+--------------+--------+------------+
| id | module_name | status | list_order |
+-----+--------------+--------+------------+
| 100 | 系统管理 | 1 | 2 |
| 600 | 环境管理 | 1 | 3 |
+-----+--------------+--------+------------+
解决办法:
杀掉原始慢查询sql即可!
xtrace版本2.2可加参数 --lock-wait-query-type=all
xtrace版本2.4可加参数 --ftwrl-wait-query-type
该选项表示获得全局锁之前允许那种查询完成,默认是ALL,可选update。
 
原因:
在flush tables with read lock成功获得锁之前,必须等待所有语句执行完成(包括SELECT)。所以如果有个慢查询在执行,或者一个打开的事务,或者其他进程拿着表锁,flush tables
 
with read lock就会被阻塞,直到所有的锁被释放。
 
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.
 
 
以上就是Mysql从库大量select堵塞处于Waiting for table flush 状态该怎么办,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。

dawei

【声明】:毕节站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

您错过了