您好,登錄后才能下訂單哦!
背景:
業(yè)務(wù)反饋在主庫(kù)上做了一個(gè)DDL操作,執(zhí)行時(shí)間很快,但是從機(jī)上卻一直報(bào)主從延遲告警。
分析:
1. 在主機(jī)上查看當(dāng)前的活動(dòng)線程,發(fā)現(xiàn)從機(jī)回放進(jìn)程處于 Waiting for table metadata lock中,但是并沒(méi)有發(fā)現(xiàn)任何其它可疑進(jìn)程。
--------+-------------+-----------------+--------+---------+---------+----------------------------------+-----------------------------------+ | Id | User | Host | db | Command | Time | State | Info | +--------+-------------+-----------------+--------+---------+---------+----------------------------------+-----------------------------------+ | 6 | system user | | NULL | Connect | 3649022 | Waiting for master to send event | NULL | | 7 | system user | | testtt | Connect | 9 | Waiting for table metadata lock | alter table v_t add column aa int | | 181873 | vector | 127.0.0.1:41634 | testtt | Query | 0 | starting | show processlist | +--------+-------------+-----------------+--------+---------+---------+----------------------------------+-----------------------------------+
2. 查看系統(tǒng)的未提交事務(wù),發(fā)現(xiàn)了一個(gè)業(yè)務(wù)進(jìn)程開(kāi)啟了事務(wù)但是一直未提交。
+-----------------+--------+------+---------------------+---------------------+------------------------------------------------------------------------------------------------------+ | host | user | time | trx_mysql_thread_id | trx_started | left(p.info,100) | +-----------------+--------+------+---------------------+---------------------+------------------------------------------------------------------------------------------------------+ | 127.0.0.1:41634 | vector | 0 | 181873 | 2020-04-23 20:41:29 | select p.host,p.user,p.time,t.trx_mysql_thread_id,t.trx_started,left(p.info,100) from information_sc | +-----------------+--------+------+---------------------+---------------------+------------------------------------------------------------------------------------------------------+
3. 手動(dòng)KILL掉這個(gè)線程后,業(yè)務(wù)恢復(fù)正常
總結(jié): 從機(jī)上也是可以通過(guò)設(shè)置set autocommit=0等方式來(lái)顯示開(kāi)啟事務(wù),從而阻塞從機(jī)回放線程的。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。