日期:2014-05-16  浏览次数:20449 次

ORA-01591 锁定已被有问题的分配事务处理--解决方法

最近,在webogic中使用两阶段提交事务,遇到了错误java.sql.SQLException: ORA-01591: 锁定已被有问题的分配事务处理8.47.144854挂起
注意:8.47.144854是事务编号

在网上找到一个比较详细解释http://www.chinageren.com/jc/HTML/120874.html

可在oracle提供的Administrator’s Guide文档中查找ORA-01591,获得相关的错误信息
英文原文:
ORA-01591: lock held by in-doubt distributed transaction identifier
我觉得中文翻译不对:锁已被有问题的分布式事务持有
意译应该是:有问题的事务持有该资源(就是你想要查询的资源)的锁,比如一些两阶段事务提交(Two-Phase Commit),出现的问题,都会出现这些问题

下面是删除该锁的示例代码

1.现在DBA_2PC_PENDING表中找到出错的事务,注意STATE字段的信息

SQL> select * from DBA_2PC_PENDING;

LOCAL_TRAN_ID?? GLOBAL_TRAN_ID?????????????? STATE???????? MIXED ADVICE TRAN_COMMENT? FAIL_TIME?? FORCE_TIME? RETRY_TIME? OS_USER???????? OS_TERMINAL? HOST?????? DB_USER? COMMIT#
-------------- ---------------------------- -------------- ----- ------ ------------- ----------- ----------- ----------- --------------- ------------ ---------- -------- -----------
8.47.144854???? 48801.00BEA9B42C3DFE95E711?? prepared?????? no???????????????????????? 2007-4-5 下???????????? 2007-4-5 下 Administrator?? unknown????? wangjian??????????? 164812088

2.提交前面发生错误的事务

SQL> COMMIT FORCE "8.47.144854";

Commit complete

3.再查看DBA_2PC_PENDING表,注意STATE字段的信息

SQL> select * from DBA_2PC_PENDING;

LOCAL_TRAN_ID? GLOBAL_TRAN_ID?????????????? STATE????????? MIXED ADVICE TRAN_COMMENT? FAIL_TIME?? FORCE_TIME? RETRY_TIME? OS_USER???????? OS_TERMINAL? HOST?????? DB_USER? COMMIT#
-------------- ---------------------------- -------------- ----- ------ ------------- ----------- ----------- ----------- --------------- ------------ ---------- -------- -----------
8.47.144854??? 48801.00BEA9B42C3DFE95E711?? forced commit? no???????????????????????? 2007-4-5 下 2007-4-5 下 2007-4-5 下 Administrator?? unknown????? wangjian