最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

MySQL slave 延遲一列 外鍵檢查和自增加鎖

 更新時(shí)間:2021年09月01日 15:02:58   作者:重慶八怪  
這篇文章是筆記的總結(jié),主要介紹了MySQL slave延遲一列,外鍵檢查和自增加鎖,感興趣的朋友可以參考下文,希望能幫助到你

MySQL slave 延遲 外鍵檢查和自增加鎖

一、現(xiàn)象

延遲大,大事物。

  • 表結(jié)構(gòu)

  • 無(wú)IO

  • SQL THREAD占用CPU 100%

二、pscak 采樣

采樣30個(gè)點(diǎn)

  • 外鍵檢查 占70%

  • 自增鎖獲取 占30%

三、自增鎖獲取邏輯

邏輯如下其實(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 注意這里沒(méi)有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了。

到此這篇關(guān)于MySQL slave 延遲一列 外鍵檢查和自增加鎖的文章就介紹到這了,更多相關(guān)MySQL slave 延遲 外鍵檢查和自增加鎖內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論

治县。| 武义县| 沐川县| 香格里拉县| 木里| 大埔区| 濮阳县| 沾化县| 中卫市| 平度市| 宣化县| 临江市| 孟津县| 湘乡市| 德清县| 乳山市| 阳城县| 卓资县| 当涂县| 美姑县| 宝兴县| 广元市| 苍山县| 林口县| 和顺县| 阳西县| 濉溪县| 田东县| 榆林市| 通江县| 称多县| 兰考县| 寻乌县| 鲜城| 江油市| 南丰县| 澄江县| 沈丘县| 浮山县| 马鞍山市| 扎赉特旗|