现场报这个错,我想模拟一下,看是什么问题。
在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)太慢,需要调优。
: