Waiting for Commit Lock
来源:互联网 发布:淘宝卖腾讯会员 编辑:程序博客网 时间:2024/05/20 19:40
参考:
http://www.linuxidc.com/Linux/2016-01/127157.htm
http://m.blog.itpub.net/26250550/viewspace-2105141/
问题现在:在使用xtrabackup进行备份时,备份被阻塞,并助数据库中大量show slave status进程。
1.mysql版本信息:
mysql> select @@version;
+------------+
| @@version |
+------------+
| 5.6.19-log |
+------------+
Xtrabackup备份的时候执行flushs tables with read lock和show slave status会有可能和SQL Thread形成死锁,导致SQL Thread一直被卡主,STOP也没有用,Kill我们测试会丢失数据,只有Restart Server才行。
原因:SQL Thread的DML操作完成之后,持有rli->data_lock锁,commit的时候等待MDL_COMMIT,而flush tables with read lock之后执行的show slave status会等待rli->data_lock;修复方法是rli->data_lock锁周期只在DML操作期间持有。
2.重现操作:
(1)、创建表
CREATE TABLE
test
(id
int(10) NOT NULL AUTO_INCREMENT,age
int(11) DEFAULT '0', PRIMARY KEY (
id
), KEY
idx_age
(age
)) ENGINE=InnoDB
(2)、master上执行update test set value=sleep(20)+53 where id=1;(增加sleep(20)是为了模拟方便,所以需要是statement的binlog format,row格式不行)
(3)、等同步到slave,并且正在执行时;执行flush tables with read lock;show slave status;就会阻塞住。
3.官方详细的解释和说明:
Bug#19843808: DEADLOCK ON FLUSH TABLES WITH READ LOCK + SHOW SLAVE STATUS Problem: If a client thread on an slave does FLUSH TABLES WITH READ LOCK; then master does some updates, SHOW SLAVE STATUS in the same client will be blocked. Analysis: Execute FLUSH TABLES WITH READ LOCK on slave and at the same time execute a DML on the master. Then the DML should be made to stop at a state "Waiting for commit lock". This state means that sql thread is holding rli->data_lock and waiting for MDL_COMMIT lock. Now in the same client session where FLUSH TABLES WITH READ LOCK was executed issue SHOW SLAVE STATUS command. This command will be blocked waiting for rli->data_lock causing a dead lock. Once this happens it will not be possible to release the global read lock as "UNLOCK TABLES" command has to be issued in the same client where global read lock was acquired. This causes the dead lock. Fix: Existing code holds the rli->data_lock for the whole duration of commit operation. Instead of holding the lock for entire commit duration the code has been restructured in such a way that the lock is held only during the period when rli object is being updated.
0 0
- Waiting for Commit Lock
- MySQL5.6.12 Waiting for commit lock导致从库hang住的问题剖析
- Waiting for table metadata lock
- Waiting for table metadata lock
- Waiting for table metadata lock
- Waiting for table metadata lock
- mysql Waiting for table level lock
- mysql-之Waiting for table metadata lock
- 记一次Waiting for table metadata lock
- sbt构建scala project: Waiting for lock
- mysql Waiting for table metadata lock
- 一次关于Waiting for table metadata lock的处理
- waiting for transaction lock on /var/lib/rpm/__db.000
- Hive 元数据“waiting for table metadata lock”
- 服务器上有sql状态 Waiting for query cache lock
- warning: waiting for transaction lock on /var/lib/
- MySQL表Waiting for table level lock解决
- Waiting for table metadata lock问题的解决
- HDU2665 Kth number(主席树入门)
- RocketMQ使用步骤--- 开发测试环境搭建及Java用例
- C/C++函数srand()和rand()的使用
- 关于scroolView自己慢慢滑动的动画
- Android图片压缩(质量压缩和尺寸压缩)
- Waiting for Commit Lock
- Android UI性能优化实战 识别绘制中的性能问题。解决CPU绘制过度
- H3C三层交换机通用的四个步骤
- 开源项目——小Q聊天机器人V1.5
- SpringBoot中通过配置文件控制路径和变量(三)
- C++作业6
- 让UITableView的headerview不悬停的方法
- Apache2.2与Tomcat7集成方案详解
- 租房签合同之前的注意事项