2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > oracle 分布式事务处理等待锁 关于“ORA-02049: 超时: 分布式事务处理等待锁”的处理过程...

oracle 分布式事务处理等待锁 关于“ORA-02049: 超时: 分布式事务处理等待锁”的处理过程...

时间:2020-11-23 15:21:20

相关推荐

oracle 分布式事务处理等待锁 关于“ORA-02049: 超时: 分布式事务处理等待锁”的处理过程...

今晚接到项目经理发来的数据库问题,报错为ORA-02049: 超时: 分布式事务处理等待锁,第一时间感觉是维护的数据库的dblink问题,因为现在维护的这些数据库使用大量dblink,70%以上的查询都使用dblink,查看对于的存储过程发现,在循环处理后没有commit,导致该问题的出现。

下面是在测试环境的模拟:

连接第一个数据库,查看DISTRIBUTED_LOCK_TIMEOUT参数的值为60,创建测试表,并产生一个事务,不提交

SQL> show parameter DISTRIBUTED_LOCK_TIMEOUT

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

distributed_lock_timeout integer 60

SQL> create table t_herman

2 (id number(10),

3 name varchar(20));

Table created.

SQL> insert into t_herman values(0,'test');

1 row created.

SQL> commit;

Commit complete.

SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

TO_CHAR(SYSDATE,'YY

-------------------

-07-25 20:40:36

SQL> update t_herman set name='abc' where id=0;

1 row updated.

连接第二个数据库,创建dblink连接第一个数据库,并修改上面表的对于行的数据,等待60秒,产生ORA-02049错误

[ABPCS01]/oracle#sqlplus system/oracle

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 25 20:35:39

Copyright (c) 1982, , Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show parameter DISTRIBUTED_LOCK_TIMEOUT

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

distributed_lock_timeout integer 60

SQL> create database link to_hss217 CONNECT TO system IDENTIFIED BY oracle USING 'HSSDB_217';

Database link created.

SQL> update t_herman@to_hss217 set name='xyz' where id=0;

update t_herman@to_hss217 set name='xyz' where id=0

*

ERROR at line 1:

ORA-02049: timeout: distributed transaction waiting for lock

ORA-02063: preceding line from TO_HSS217

总结:

DISTRIBUTED_LOCK_TIMEOUT:specifies the amount of time (in seconds) for distributed transactions to wait for locked resources.

该参数指定等待分布式锁资源的时间,超过这个时间事务自动回滚,即在等待未释放的资源超过一定的时间,系统自动报错给客户端

该值默认为60,即等待分布式锁资源60秒

从上面的测试来看,使用dblink做分布式事务时一定要及时commit或rollback,尽量在分布式应用中使用短事务为宜

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。