您好,登錄后才能下訂單哦!
背景:
業務反饋在主庫上做了一個DDL操作,執行時間很快,但是從機上卻一直報主從延遲告警。
分析:
1. 在主機上查看當前的活動線程,發現從機回放進程處于 Waiting for table metadata lock中,但是并沒有發現任何其它可疑進程。
--------+-------------+-----------------+--------+---------+---------+----------------------------------+-----------------------------------+ | 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. 查看系統的未提交事務,發現了一個業務進程開啟了事務但是一直未提交。
+-----------------+--------+------+---------------------+---------------------+------------------------------------------------------------------------------------------------------+ | 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. 手動KILL掉這個線程后,業務恢復正常
總結: 從機上也是可以通過設置set autocommit=0等方式來顯示開啟事務,從而阻塞從機回放線程的。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。