今天同事在执行一个update的时候,报错:
update test_table set servstatus='T' where servid in (
*
ERROR at line 1:
ORA-01591: lock held by in-doubt distributed transaction 2.28.6903
其中service是一个用db link连接远程数据库的同义词。
此时,检查dba_2pc_pending:
SQL>select LOCAL_TRAN_ID from dba_2pc_pending;
LOCAL_TRAN_ID
----------------------
2.28.6903
=========================================================
发现确实发生了pending事务。尝试rollback force:
SQL> rollback force 2.28.6903;
rollback force 2.28.6903
*
ERROR at line 1:
ORA-00922: missing or invalid option
SQL> commit force 2.28.6903
2 ;
commit force 2.28.6903
*
ERROR at line 1:
ORA-00922: missing or invalid option
==========================================================
发现无法做rollback或者commit,按照论坛中托马斯张的方法进行处理:
SQL> delete from sys.pending_trans$ where local_tran_id ='2.28.6903';
delete from sys.pending_trans$ where local_tran_id ='2.28.6903'
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL> conn / as sysdba
Connected.
SQL> show user
USER is "SYS"
SQL> delete from sys.pending_trans$ where local_tran_id ='2.28.6903';
1 row deleted.
SQL> delete from sys.pending_sessions$ where local_tran_id ='2.28.6903' ;
1 row deleted.
SQL> delete from sys.pending_sub_sessions$ where local_tran_id ='2.28.6903';
1 row deleted.
SQL> commit
2 ;
Commit complete.
SQL>
SQL> select LOCAL_TRAN_ID from dba_2pc_pending;
no rows selected
==========================================================
按理来说到这里,问题已经解决,但是同事在继续执行原来的update的时候还是报同样的错,而且退出后重新登录,再次执行,还是报错:
SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
[oracle@gd-simsdb oracle]$ sqlplus USER/PWD
SQL*Plus: Release 9.2.0.6.0 - Production on Wed Apr 11 18:14:22 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
SQL>
SQL>
SQL>
SQL>
SQL> UPDATE test_table
2 SET servstatus = 'T'
3 WHERE servid IN
4 (a, b, c, d,
……
13 x, y, z);
UPDATE service
*
ERROR at line 1:
ORA-01591: lock held by in-doubt distributed transaction 2.28.6903
SQL>
SQL>
SQL> select * from dba_2pc_pending;
no rows selected
SQL> select 1 from dual@DB_LINK;
1
----------
1
==========================================================
请教各位,这样的情况,该如何处理呢?为什么还是会有in-doubt distributed transaction?