MySQL5.6 + xtrabackup 死锁,Waiting for Commit Lock
发表于:2025-11-08 作者:千家信息网编辑
千家信息网最后更新 2025年11月08日,http://www.ttlsa.com/mysql/mysql5-6-waiting-for-commit-lock/http://bugs.mysql.com/bug.php?id=70307使用
千家信息网最后更新 2025年11月08日MySQL5.6 + xtrabackup 死锁,Waiting for Commit Lock
http://www.ttlsa.com/mysql/mysql5-6-waiting-for-commit-lock/
http://bugs.mysql.com/bug.php?id=70307
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操作期间持有。
http://www.ttlsa.com/mysql/mysql5-6-waiting-for-commit-lock/
http://bugs.mysql.com/bug.php?id=70307

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操作期间持有。
重现步骤:
一、创建表 CREATE TABLE test ( id int(10) NOT NULL AUTO_INCREMENT, age int(11) DEFAULT '0', PRIMARY KEY (id), KEY idx_age (age)) ENGINE=InnoDB
二、master上执行update test set value=sleep(20)+53 where id=1;(增加sleep(20)是为了模拟方便,所以需要是statement的binlog format,row格式不行) 三、等同步到slave,并且正在执行时;执行flush tables with read lock;show slave status;就会阻塞住。官方详细的解释和说明:
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.
时候
死锁
不行
原因
只有
周期
备份
官方
数据
方法
有用
格式
正在
步骤
要是
测试
解释
阻塞
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
佰众云科软件开发
高考志愿软件开发
数据库中电话号码 住址
有大学交友软件开发
代理服务器自动关闭如何解决
金太阳网络技术有限公司
网络安全校园教育活动感想
市领导网络安全讲话稿
大学生网络安全教育是什么
广东定制软件开发排行榜
高校忽视网络安全教育
软件开发过程漫画
中央数据库保障人群学生
哪个服务器电脑版和手机版一样
怎么区分文件和数据库
美术网络技术培训心得
免费服务器图形化监控管理
软件开发营销策略
中国物联网网络安全
局域网内如何设置管理服务器
小程序云数据库是什么数据库
网络安全入侵检测的核心
数据库设计过程中技巧性最强的
医疗器械软件开发计划
长春培训班软件开发速成
斯塔德网络技术
梅县网络安全和信息化委员会
经纬软件开发
软件开发项目经理实操手册
深圳市心科网络技术有限公司