国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 課堂 > 基礎(chǔ)知識 > 正文

關(guān)于innodb_rollback_on_timeout測驗

2024-09-12 20:29:58
字體:
供稿:網(wǎng)友
  innodb_rollback_on_timeout
  innodb_lock_wait_timeout
  最開始看到innodb_rollback_on_timeout 時,沒有好好理解transaction timeout的意思.以為只要是連接超時就會觸發(fā),今天研究了一下.只能說巨坑;
  以下測試.隔離級別皆為RR模式.測試過程.
  
  實驗一:
  innodb_rollback_on_timeout =on
  innodb_lock_wait_timeout=20    
  ---------------------------------------|----------------------------------------|------------------------------------------------
  session 1                             |            session 2                   |         session  3   
  ---------------------------------------|----------------------------------------|------------------------------------------------
   begin;                               |                                        |select * from information_schema.innodb_trx
                                         |                                        |      order by trx_started;   
  ---------------------------------------|----------------------------------------|------------------------------------------------
  insert into t8 values (20,'ddd');      |                                        |       1   
  ---------------------------------------|----------------------------------------|------------------------------------------------
                                         |            begin;                     |      2   
  ---------------------------------------|----------------------------------------|------------------------------------------------
                                         | update t8 set test1='yyy' where id =19;|           2   
  ---------------------------------------|----------------------------------------|------------------------------------------------
                                         |                                        |       2   
  update t8 set test1='xxx' where id =19;|                                        |
  ---------------------------------------|----------------------------------------|------------------------------------------------
                 堵塞                    |                                        |          2
  ---------------------------------------|----------------------------------------|------------------------------------------------
  20s后超時                              |                                        |       1   
  事務結(jié)束;                              |    commit;                             |     0
  ---------------------------------------|----------------------------------------|------------------------------------------------     
  
 
  select * from t8;    
  20這個id沒有;19被改為yyy;    
    
    
  實驗二:
  innodb_rollback_on_timeout =off
  innodb_lock_wait_timeout=20   
  ---------------------------------------|---------------------------------------|-----------------------------------------------
                   session 1             |                   session 2          |          session  3   
  ---------------------------------------|---------------------------------------|-----------------------------------------------
   begin;                               |                                       | select * from information_schema.innodb_trx
                                         |                                       |        order by trx_started;   
  ---------------------------------------|---------------------------------------|-----------------------------------------------
  insert into t8 values (20,'ddd');      |                                       |              1   
  ---------------------------------------|---------------------------------------|-----------------------------------------------
                                         |                   begin;              |             2   
                                         |update t8 set test1='yyy' where id =19;|
  ---------------------------------------|---------------------------------------|-----------------------------------------------
  update t8 set test1='xxx' where id =19;|                                       |               2
  ---------------------------------------|---------------------------------------|-----------------------------------------------
  堵塞                                   |                                       |               2     
  ---------------------------------------|---------------------------------------|-----------------------------------------------
  20s后超時                              |                                       |              2   
  事務未結(jié)束                           |                                       |
  ---------------------------------------|---------------------------------------|-----------------------------------------------
      commit;                            |                       commit;         |               0   
  ---------------------------------------|---------------------------------------|-----------------------------------------------
    
  select * from t8;    
  20這個id存在;19被改為yyy;  
  
  結(jié)果就是:如果innodb_rollback_on_timeout 為on,事務在innodb_lock_wait_timeout超時后,當前sql會報超時,并使整個事務都回滾,然后結(jié)束事務;
           如果innodb_rollback_on_timeout 為off(默認值),事務在innodb_lock_wait_timeout超時后,當前sql會超時,并終止,回滾當前sql,但整個事務不回滾,事務不結(jié)束,必須顯示的回滾或提交;
   一句話:innodb_rollback_on_timeout 沒什么卵用.純碎就是坑;

(編輯:武林網(wǎng))

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 社会| 永修县| 长汀县| 嘉黎县| 简阳市| 石台县| 青岛市| 锡林浩特市| 四子王旗| 临潭县| 阿城市| 云阳县| 泗阳县| 阿拉善盟| 贵溪市| 大冶市| 广州市| 长汀县| 库车县| 长武县| 大埔区| 大悟县| 河间市| 昭通市| 宜昌市| 涪陵区| 碌曲县| 洛川县| 平山县| 南京市| 广州市| 平顶山市| 隆德县| 和田市| 尼玛县| 滕州市| 呼伦贝尔市| 朝阳市| 云浮市| 丘北县| 开原市|