慢查询和innobackup备份导致数据库挂起

来源:互联网 发布:怎样查看linux登录锁定 编辑:程序博客网 时间:2024/06/18 11:38

现象

  • 短信报警凌晨的备份任务失败;
  • 研发说应用挂了,应用都重启过了,貌似还没解决;
  • 其他cpu、磁盘空间、日志等指标都正常,没收到报警,疑惑;

排查

  • 凌晨1点开始的备份不成功:

>> log scanned up to (348743804470)xtrabackup: Creating suspend file '/data1/backup/2017-11-14_01-00-06/xtrabackup_suspended_2' with pid '3048'171114 01:06:15  innobackupex: Continuing after ibbackup has suspended171114 01:06:15  innobackupex: Executing FLUSH NO_WRITE_TO_BINLOG TABLES...>> log scanned up to (348743819365)>> log scanned up to (348743830358)>> log scanned up to (348743838117)>> log scanned up to (348743848569)……

  • 同时,某个慢查询已经执行了1个多小时还没完成,一直Sending data状态;
  • 大量SQL开始等待,状态:Waiting for table flush

分析

关于Waiting for table flush,官方说明:
The thread is executing FLUSH TABLES and is waiting for all threads to close their tables, or 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,
本案中大量进程Waiting for table flush,就是等待innobackup flush table后,close这些表。但innobackup被慢查询卡住了。

解决

innobackup有几个参数可以应对这种情况:
--kill-long-queries-timeout=N (seconds) 
how many time we give for queries to complete after FLUSH TABLES WITH READ LOCK is issued before start to kill. Default if 0, not to kill.
--kill-long-query-type={all|select} 
which queries should be killed once kill-long-queries-timeout has expired.
举例:
innobackupex --user=root --password=password --kill-long-queries-timeout=30 --kill-long-query-type=all /backup/
innobackup等待30秒后,杀死堵塞的进程,可以顺利完成备份,不会对其他DML操作产生影响。


阅读全文
0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 帮人炒股亏了很多钱怎么办 破净买入继续跌怎么办 国画颜色上错了怎么办 宝宝5个月脸一直开裂怎么办 宝宝冻脸怎么办小妙招 3岁小儿长期便秘怎么办 脚裂了怎么办小妙招 宝宝脸风吹裂了怎么办 宝宝脸被风吹裂了怎么办 小宝贝的手有时候抖怎么办 打球把手戳肿了怎么办 阴茎上皮肤皴了怎么办 手皮肤干燥起皮怎么办 一到冬天手脚冰凉怎么办 脸上的皮肤被搓掉了怎么办 皮肤的表皮搓掉了怎么办 固体水彩经常掉出来怎么办 画水彩纸皱了怎么办 画完水彩纸皱了怎么办 旗袍后面隐形拉链气包怎么办 电动缝纫机不往前走怎么办 衬衣领子磨烂了怎么办 白寸衣领变黄怎么办 黑衣领衣服洗发黄怎么办 白毛衣用84变黄怎么办 白色貂毛衣变黄怎么办 蓝色T恤衣领汗積洗不掉怎么办 蓝色t恤衣领汗积洗不掉怎么办 羽绒服在衣柜里放黄了怎么办 白羽绒服放久了泛黄怎么办 白色t恤领子发黄怎么办 身体爱出油衣服领子总爱脏怎么办 白色衣服衣领净洗后变红怎么办 棒球服衣领洗变形怎么办 挂盐水手肿了怎么办 衣服买大了肩宽怎么办 买来的衣服肩宽怎么办 素描揉擦之后的黑点怎么办 扭脖子响了一下怎么办 画的眼线容易掉怎么办 做完眼线后眼睛肿了怎么办