现场报这个错,我想模拟一下,,看是什么问题。
在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)太慢,需要调优。
本文永久更新链接地址:
