您好,登錄后才能下訂單哦!
RAC如何進(jìn)行死鎖檢測(cè)時(shí)間,很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
對(duì)于單實(shí)例數(shù)據(jù)庫而言,死鎖的檢測(cè)在秒級(jí)完成,而RAC環(huán)境則死鎖的檢測(cè)時(shí)間默認(rèn)達(dá)到了1分鐘。
對(duì)于單實(shí)例環(huán)境如果出現(xiàn)了死鎖,那么馬上其中一個(gè)進(jìn)程就被中止,用戶可以快速的得到錯(cuò)誤返回。而對(duì)于RAC而言,死鎖的檢測(cè)并不是實(shí)時(shí)完成,而是需要60秒左右的時(shí)間。
會(huì)話1執(zhí)行:
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
會(huì)話2執(zhí)行:
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;
此時(shí),會(huì)話2等待會(huì)話1的最終操作,下面會(huì)話1更新被會(huì)話2鎖定的行,引發(fā)死鎖:
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
可以看到,死鎖的超時(shí)檢測(cè)為1分鐘。
而這個(gè)死鎖的檢測(cè)時(shí)間是可以調(diào)整的,Oracle通過隱含參數(shù)_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 bytes
Redo Buffers 6291456 bytes
Database mounted.
Database opened.
再次測(cè)試死鎖的檢測(cè)時(shí)間,會(huì)話1:
SQL> update t_deadlock set name = 'a1' where id = 1;
1 row updated.
SQL> set timing on
會(huì)話2執(zhí)行更新:
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;
會(huì)話1執(zhí)行更新引發(fā)死鎖:
SQL> update t_deadlock set name = 'b1' where id = 2;
大約30秒后,會(huì)話2報(bào)錯(cuò)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存在一個(gè)bug,允許這個(gè)參數(shù)設(shè)置為0,在10.2.0.3以后,這個(gè)bug被修正,如果設(shè)置為0后,則數(shù)據(jù)庫無法正常啟動(dòng):
[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
最后修改隱含參數(shù)是Oracle不推薦的,而且修改這個(gè)參數(shù)勢(shì)必會(huì)影響RAC的正常工作方式導(dǎo)致LDM進(jìn)程的繁忙度增加,而且可能影響RAC環(huán)境的穩(wěn)定性和可用性。
如果確實(shí)對(duì)于前臺(tái)的死鎖檢查時(shí)間要求較高,建議在測(cè)試環(huán)境中詳細(xì)測(cè)試后再部署到產(chǎn)品環(huán)境中。
看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注億速云行業(yè)資訊頻道,感謝您對(duì)億速云的支持。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。