ORA-02049: 逾時: 分散式交易處理等待鎖類比

來源:互聯網
上載者:User

ORA-02049: 逾時: 分散式交易處理等待鎖類比

現場報這個錯,我想類比一下,看是什麼問題。

在Oracle資料庫B上建表:

create table TEST
(
  A NUMBER,
  B DATE
);
insert into test (A, B) values (2, to_date('16-04-2015 16:38:26', 'dd-mm-yyyy hh24:mi:ss'));
insert into test (A, B) values (1, to_date('24-03-2015 16:32:36', 'dd-mm-yyyy hh24:mi:ss'));
insert into test (A, B) values (2, to_date('16-04-2015 16:35:19', 'dd-mm-yyyy hh24:mi:ss'));
insert into test (A, B) values (2, to_date('16-04-2015 16:35:19', 'dd-mm-yyyy hh24:mi:ss'));
commit;

在資料庫A上:
drop  database link to_B;
create  database link to_B
connect to B_user  identified by B_password
using '(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.15.10)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )';

在資料庫B上執行update不提交:
SQL> update test set b = sysdate where A =2;

在資料庫A上:
SQL> show parameter distributed_lock_timeout;
NAME                                TYPE        VALUE
------------------------------------ ----------- -------
distributed_lock_timeout            integer    60

SQL> update test@to_B set b = sysdate where A =2;
update test@to_B set b = sysdate where A =2
*
第 1 行出現錯誤:
ORA-02049: 逾時: 分散式交易處理等待鎖

ORA-02063: 緊接著 line (起自 TO_B)

等待60s後就報逾時,就是distributed_lock_timeout設定的值

解決方案:資料庫B上的事務儘快提交,或者資料庫B上的SQL(update or delete or merge)太慢,需要調優。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.