http://www.ttlsa.com/MySQL/mysql5-6-waiting-for-commit-lock/
http://bugs.mysql.com/bug.php?id=70307
公司主營業(yè)務(wù):網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站設(shè)計(jì)、移動(dòng)網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。成都創(chuàng)新互聯(lián)是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來驚喜。成都創(chuàng)新互聯(lián)推出北戴河免費(fèi)做網(wǎng)站回饋大家。
使用MySQL5.6和Xtrabackup的小心一個(gè)bug,http://bugs.mysql.com/bug.php?id=70307,這個(gè)bug在5.6.23中已經(jīng)修復(fù)。
Xtrabackup備份的時(shí)候執(zhí)行flushs tables with read lock和show slave status會(huì)有可能和SQL Thread形成死鎖,導(dǎo)致SQL Thread一直被卡主,STOP也沒有用,Kill我們測(cè)試會(huì)丟失數(shù)據(jù),只有Restart Server才行。
原因是SQL Thread的DML操作完成之后,持有rli->data_lock鎖,commit的時(shí)候等待MDL_COMMIT,而flush tables with read lock之后執(zhí)行的show slave status會(huì)等待rli->data_lock;修復(fù)方法是rli->data_lock鎖周期只在DML操作期間持有。
重現(xiàn)步驟:
一、創(chuàng)建表
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上執(zhí)行update test set value=sleep(20)+53 where id=1;(增加sleep(20)是為了模擬方便,所以需要是statement的binlog format,row格式不行)
三、等同步到slave,并且正在執(zhí)行時(shí);執(zhí)行flush tables with read lock;show slave status;就會(huì)阻塞住。
官方詳細(xì)的解釋和說明:
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.
新聞標(biāo)題:MySQL5.6+xtrabackup死鎖,WaitingforCommitLock
當(dāng)前鏈接:http://jinyejixie.com/article42/pgihec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、靜態(tài)網(wǎng)站、網(wǎng)站制作、全網(wǎng)營銷推廣、搜索引擎優(yōu)化、軟件開發(fā)
廣告
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源:
創(chuàng)新互聯(lián)