ORA-01591: lock held by in-doubt distributed transaction and then purge the in-doubt transaction

#Issue 

ORA-01591: lock held by in-doubt distributed transaction 2.96.17311
when executing the following sql statement  


SELECT * FROM COMPLAINT WHERE case_no='AP1706098703' ;


Error:  ORA-01591 lock held by in-doubt distributed transaction %s 
---------------------------------------------------------------------------
Cause:  Trying to access resource that is locked by a dead two-phase commit 
	transaction that is in prepared state. 
Action: DBA should query the pending_trans$ and related tables, and attempt to 
	repair network connection(s) to coordinator and commit point. If timely 
	repair is not possible, DBA should contact DBA at commit point if known 
	or end user for correct outcome, or use heuristic default if given to 
	issue a heuristic commit or abort command to finalize the local portion 
	of the distributed transaction. 


# Solution


We can force a transaction in either two ways:


ROLLBACK FORCE 'transaction_id';
-OR-
COMMIT FORCE 'transaction_id',commit#;

SQL> SELECT * FROM dba_2pc_pending;
 
2.96.17311             CCMSOFT.942b8212.2.96.17311


Here 2.96.17311  is transaction that is held
 
SELECT local_tran_id  ,state ,status FROM sys.pending_trans$;
 
2.96.17311             prepared         P
 
SQL> commit force '2.96.17311';
 
Commit complete.
 

To purge the in-doubt transaction entry:


execute DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY('2.96.17311');

commit;



Post a Comment

And that's all there is to it!

If anyone has any other questions or requests for future How To posts, you can either ask them in the comments or email me. Please don't feel shy at all!

I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

Previous Post Next Post