延遲大,大事物。
創(chuàng)新互聯(lián)的客戶來(lái)自各行各業(yè),為了共同目標(biāo),我們?cè)诠ぷ魃厦芮信浜?,從?chuàng)業(yè)型小企業(yè)到企事業(yè)單位,感謝他們對(duì)我們的要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來(lái)驚喜。專業(yè)領(lǐng)域包括成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)、外貿(mào)營(yíng)銷網(wǎng)站建設(shè)、電商網(wǎng)站開發(fā)、微信營(yíng)銷、系統(tǒng)平臺(tái)開發(fā)。
表結(jié)構(gòu)
image.png
無(wú)IO
image.png
SQL THREAD占用CPU 100%
image.png
采樣30個(gè)點(diǎn)
外鍵檢查 占70%
image.png
自增鎖獲取 占30%
image.png
邏輯如下其實(shí)也是innodb_autoinc_lock_mode參數(shù)的作用
switch (lock_mode) { case AUTOINC_NO_LOCKING://innodb_autoinc_lock_mode=2 /* Acquire only the AUTOINC mutex. */ dict_table_autoinc_lock(m_prebuilt->table); break; case AUTOINC_NEW_STYLE_LOCKING: // innodb_autoinc_lock_mode=1 注意這里沒有break 巧妙的完成了邏輯 /* For simple (single/multi) row INSERTs, we fallback to the old style only if another transaction has already acquired the AUTOINC lock on behalf of a LOAD FILE or INSERT ... SELECT etc. type of statement. */ if (thd_sql_command(m_user_thd) == SQLCOM_INSERT || thd_sql_command(m_user_thd) == SQLCOM_REPLACE) { dict_table_t* ib_table = m_prebuilt->table; /* Acquire the AUTOINC mutex. */ dict_table_autoinc_lock(ib_table); /* We need to check that another transaction isn't already holding the AUTOINC lock on the table. */ if (ib_table->n_waiting_or_granted_auto_inc_locks) { /* Release the mutex to avoid deadlocks. */ dict_table_autoinc_unlock(ib_table); } else { break; } } /* Fall through to old style locking. */ case AUTOINC_OLD_STYLE_LOCKING://innodb_autoinc_lock_mode=0 觸發(fā) DBUG_EXECUTE_IF("die_if_autoinc_old_lock_style_used", ut_ad(0);); error = row_lock_table_autoinc_for_MySQL(m_prebuilt); //這個(gè)函數(shù)上表上的自增鎖 if (error == DB_SUCCESS) { /* Acquire the AUTOINC mutex. */ dict_table_autoinc_lock(m_prebuilt->table); } break; default: ut_error; }
binlog row格式,innodb_autoinc_lock_mode=1 按理說(shuō)不會(huì)觸發(fā)row_lock_table_autoinc_for_mysql加自增鎖。不知道什么原因。當(dāng)前知道:
如果主庫(kù)語(yǔ)句模式,從庫(kù)innodb_autoinc_lock_mode=1 ,insert select 肯定會(huì)觸發(fā)。
如果從庫(kù) innodb_autoinc_lock_mode=0 肯定會(huì)觸發(fā)。
但是都不滿足。疑惑。
刪除外鍵
innodb_autoinc_lock_mode設(shè)置為2,從邏輯來(lái)看肯定不會(huì)做row_lock_table_autoinc_for_mysql了。
作者微信:
微信.jpg
標(biāo)題名稱:MySQL:slave延遲一列外鍵檢查和自增加鎖
文章轉(zhuǎn)載:http://jinyejixie.com/article32/jjegsc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)、網(wǎng)站設(shè)計(jì)公司、網(wǎng)頁(yè)設(shè)計(jì)公司、App設(shè)計(jì)、網(wǎng)站排名、網(wǎng)站維護(hù)
聲明:本網(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í)需注明來(lái)源: 創(chuàng)新互聯(lián)
營(yíng)銷型網(wǎng)站建設(shè)知識(shí)