MySQL5.6 + xtrabackup 死锁,Waiting for Commit Lock
发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,http://www.ttlsa.com/mysql/mysql5-6-waiting-for-commit-lock/http://bugs.mysql.com/bug.php?id=70307使用
千家信息网最后更新 2026年11月02日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安全错误
数据库的锁怎样保障安全
互联网科技有限公司
南京欣网互联网络科技
中国互联网科技股
科技与互联网
智网互联网科技
致骋互联网科技
紫鲸互联网科技
润盈互联网科技
郑州华宇互联网科技
哈尔滨新华互联网科技
中正互联网科技招聘
蓝色互联网科技
来此购互联网科技有限公司
深圳市罗太互联网科技有限公司
四川慕妮娅互联网科技有限公司
烟台灵鸽互联网科技有限公司
区块链结合互联网科技
北京市互联网新科技
上海乐五互联网科技有限公司
互联网科技手抄报图片
互联网与新科技
沃里互联网科技
唐信互联网科技 大连
互联网 视角下的科技创新
互联网科技视频素材
互联网科技咨询
博兴的互联网电子科技公司
福建科技产业互联网发展
中国互联网公司排名锤子科技
黑科技 体验场景 互联网大会