tbwshc

          RAC全局死鎖檢測時間

          對于單實例數據庫而言,死鎖的檢測在秒級完成,而RAC環境則死鎖的檢測時間默認達到了1分鐘。

           

           

          對于單實例環境如果出現了死鎖,那么馬上其中一個進程就被中止,用戶可以快速的得到錯誤返回。而對于RAC而言,死鎖的檢測并不是實時完成,而是需要60秒左右的時間。

          會話1執行:

          SQL> create table t_deadlock (id number primary key, name varchar2(30));

          Table created.

          Elapsed: 00:00:00.12
          SQL> insert into t_deadlock values (1, 'a');

          1 row created.

          Elapsed: 00:00:00.00
          SQL> insert into t_deadlock values (2, 'b');

          1 row created.

          Elapsed: 00:00:00.00
          SQL> commit;

          Commit complete.

          Elapsed: 00:00:00.00
          SQL> update t_deadlock set name = 'a1' where id = 1;

          1 row updated.

          Elapsed: 00:00:00.00

          會話2執行:

          SQL> set timing on
          SQL> update t_deadlock set name = 'b2' where id = 2;

          1 row updated.

          Elapsed: 00:00:00.00
          SQL> update t_deadlock set name = 'a2' where id = 1;

          此時,會話2等待會話1的最終操作,下面會話1更新被會話2鎖定的行,引發死鎖:

          SQL> update t_deadlock set name = 'b1' where id = 2;
          update t_deadlock set name = 'b1' where id = 2
          *
          ERROR at line 1:
          ORA-00060: deadlock detected while waiting for resource


          Elapsed: 00:01:00.12

          可以看到,死鎖的超時檢測為1分鐘。

          而這個死鎖的檢測時間是可以調整的,Oracle通過隱含參數_lm_dd_interval控制:

          SQL> conn / as sysdba
          Connected.
          SQL> alter system set "_lm_dd_interval" = 30 scope = spfile;

          System altered.

          SQL> shutdown immediate
          Database closed.
          Database dismounted.
          ORACLE instance shut down.
          SQL> startup
          ORACLE instance started.

          Total System Global Area 281018368 bytes
          Fixed Size 2095672 bytes
          Variable Size 104859080 bytes
          Database Buffers 167772160 tb bytes
          Redo Buffers 6291456 bytes
          Database mounted.
          Database opened.

          再次測試死鎖的檢測時間,會話1:

          SQL> update t_deadlock set name = 'a1' where id = 1;

          1 row updated.

          SQL> set timing on

          會話2執行更新:

          SQL> set timing on
          SQL> update t_deadlock set name = 'b2' where id = 2;

          1 row updated.

          Elapsed: 00:00:00.02
          SQL> update t_deadlock set name = 'a2' where id = 1;

          會話1執行更新引發死鎖:

          SQL> update t_deadlock set name = 'b1' where id = 2;

          大約30秒后,會話2報錯ORA-60:

          update t_deadlock set name = 'a2' where id = 1
          *
          ERROR at line 1:
          ORA-00060: deadlock detected while waiting for resource


          Elapsed: 00:00:30.27

          在10.2.0.2版本上,Oracle存在一個bug,允許這個參數設置為0,在10.2.0.3以后,這個bug被修正,如果設置為0后,則數據庫無法正常啟動:

          [oracle@node1 ~]$ sqlplus / as sysdba

          SQL*Plus: Release 10.2.0.5.0 - Production on Mon Jun 4 07:54:09 2012

          Copyright (c) 1982, 2010, Oracle. All Rights Reserved.

          Connected to an idle instance.

          SQL> startup
          ORA-00067: invalid value 0 for parameter _lm_dd_interval; must be at least 1

          最后修改隱含參數是Oracle不推薦的,而且修改這個參數勢必會影響RAC的正常工作方式導致LDM進程的繁忙度增加,而且可能影響RAC環境的穩定性和可用性。

          如果確實對于前臺的死鎖檢查時間要求較高,建議在測試環境中詳細測試后再部署到產品環境中。

           


          posted on 2012-09-04 17:08 chen11-1 閱讀(892) 評論(0)  編輯  收藏

          My Links

          Blog Stats

          常用鏈接

          留言簿(4)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          新聞檔案

          tbw淘寶商城-首頁

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 抚宁县| 礼泉县| 醴陵市| 沂水县| 政和县| 吴川市| 河池市| 甘谷县| 佛教| 乳源| 布尔津县| 黑河市| 建德市| 山西省| 普安县| 防城港市| 龙岩市| 手机| 通江县| 绥棱县| 棋牌| 措勤县| 华容县| 二连浩特市| 嘉善县| 祥云县| 永和县| 会宁县| 乐平市| 龙州县| 鲜城| 岳西县| 阳信县| 翼城县| 塔河县| 永春县| 集安市| 吉林市| 建昌县| 容城县| 和政县|