#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;
Here 2.96.17311 is transaction that is held
SELECT local_tran_id ,state ,status FROM sys.pending_trans$;
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;
Tags:
Oracle