Focusing on immediate processing of the problem, only generate the processing command, COMMIT; You must perform your own search for the relevant cause

set lines 150 pagesize 1000; col PURGE_CMD for a150; select 'execute DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY('''||LOCAL_TRAN_ID||'''); '||chr(10)||'commit; ' as PURGE_CMD from DBA_2PC_PENDING where STATE in ('collecting', 'committed', 'forced rollback', 'forced commit') union all select 'rollback force '''||LOCAL_TRAN_ID||'''; '||chr(10)||'commit; ' as PURGE_CMD from DBA_2PC_PENDING where STATE = 'prepared';