oracle中ora-02049,ORA-02049 ‘timeout: distributed transaction waiting for lock’ 解决
ORA-02049 ‘timeout: distributed transaction waiting for lock’
ORA-02049是一個分布式事務等待超時的異常,當一個session 持有一個行級鎖,另一個分布式事務比如通過dblink也想修改相同行的數據,就會產生 tx隊列等待,當等待時間超過了系統參數distributed_lock_timeout的值時,就產生了這個錯誤,任何通過通過DBLINK的操作都是分布式事物。
下面還原一下這個錯誤
SQL> create table testdl(id int);
Table created.
SQL> insert into testdl values(1);
1 row created.
SQL> commit;
Commit complete.
SQL> insert into testdl values(2);
1 row created.
SQL> commit;
Commit complete.
【session1】
sys@NCME>select * from testdl@dl_1913;
ID
----------
1
2
sys@NCME>update testdl@dl_1913 set id=10 where id=1;
1 row updated.
【session2】
sys@NCME>update testdl@dl_1913 set id=20 where id=2;
1 row updated.
sys@NCME>commit;
Commit complete.
sys@NCME>update testdl@dl_1913 set id=100 where id=1;
update testdl@dl_1913 set id=100 where id=1
*
ERROR at line 1:
ORA-02049: timeout: distributed transaction waiting for lock
ORA-02063: preceding line from DL_1913
----------------
SQL> alter table testdl modify id primary key;
Table altered.
【session1】
sys@NCME>insert into testdl@dl_1913 values (3);
1 row created.
【session2】
sys@NCME>insert into testdl@dl_1913 values (3);
insert into testdl@dl_1913 values (3)
*
ERROR at line 1:
ORA-02049: timeout: distributed transaction waiting for lock
ORA-02063: preceding line from DL_1913
sys@NCME>show parameter distributed_lock
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
distributed_lock_timeout integer 60
解決問題的思路
首先還是應用程序的代碼設計,減少多個session同時修改相同數據,減小事務,或在代碼中加try do something cache exception ,when exception is ORA-02049 retry.
其次就是增加distributed_lock_timeout參數的值,增加事務等待時間
打賞
微信掃一掃,打賞作者吧~
總結
以上是生活随笔為你收集整理的oracle中ora-02049,ORA-02049 ‘timeout: distributed transaction waiting for lock’ 解决的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 喀什大学计算机科学与技术学院在哪个校区,
- 下一篇: c++调用求平方根函数_如何使用java