Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • move_arch_files.ksh /* Good One */ Linux/Unix
  • fdisk -l explaination about Primary-Logical-Extended Partitions Linux/Unix
  • TRUNCATE Privs Oracle
  • Distributed Transaction Troubleshooting. Oracle
  • standard Monitoring – 1 Oracle
  • sesswait.sql Oracle
  • switchover for primary database Oracle
  • Convert multiple rows to single column Oracle
  • .profile Linux/Unix
  • DBMS_UTILITY.ANALYZE_SCHEMA Oracle
  • Find Stale DR Physical Standby Oracle
  • Move WordPress site from one hosting service to other. PHP/MYSQL/Wordpress
  • create PLAN_TABLE command. Oracle
  • Kernel Parameters for Solaris Linux/Unix
  • catall.sh Linux/Unix

How To Resolve Stranded DBA_2PC_PENDING Entries ID 401302.1 (Very Good prooven)

Posted on 11-Nov-2010 By Admin No Comments on How To Resolve Stranded DBA_2PC_PENDING Entries ID 401302.1 (Very Good prooven)

Ref ID: How To Resolve Stranded DBA_2PC_PENDING Entries [ID 401302.1]

Issue: We had network outage and there were some distributed transactions with dblinks hangs. Causing issue when trying to update some rows of the base table.

Problem Discription:

====================

As a result of a failed commit of a distributed transaction, some entries canbe left in dba_2pc views, i.e. dba_2pc_pending and dba_2pc_neighbors. The RECO process checks these views to recover the failed txn. However, in some cases RECO cannot perform the recovery. One cause is that all sites involved in thetransaction not being accessible at the same time. Another cause is dba_2pc views being inconsistent with the transaction table.

Solutions:

==========

Case:1 Dba_2pc entries without a corresponding transaction

==========================================================

In this case dba_2pc views show distributed transactions but there are no txnsin reality.

If the state of the transaction is committed, rollback forced or commit forced then this is normal and it can be cleaned up using dbms_transaction.purge_lost_db_entry.

If the state of the transaction is PREPARED and there is no entry in the transaction table for it then this entry can be cleaned up manually as follows:

set transaction use rollback segment SYSTEM;

delete from sys.pending_trans$ where local_tran_id = ;

delete from sys.pending_sessions$ where local_tran_id = ;

delete from sys.pending_sub_sessions$ where local_tran_id = ;

commit;

For Example:

————

The following query reports a dist. txn. in prepared state

select local_tran_id, state from dba_2pc_pending;

LOCAL_TRAN_ID STATE

———————- —————-

1.92.66874 prepared

Given that a transaction id is composed of ‘1.92.66874’ is located in rollback segment# 1. To find out the list of active transactions in that rollback segment, use:

SELECT KTUXEUSN, KTUXESLT, KTUXESQN, /* Transaction ID */

KTUXESTA Status,

KTUXECFL Flags

FROM x$ktuxe

WHERE ktuxesta!=’INACTIVE’

AND ktuxeusn= 1; <== this is the rollback segment# no rows selected It is not possible to rollback force or commit force this transaction.
SQL> rollback force ‘1.92.66874’;

ORA-02058: no prepared transaction found with ID 1.92.66874

Hence, we have to manually cleanup that transaction:

set transaction use rollback segment SYSTEM;

delete from sys.pending_trans$where local_tran_id = ‘1.92.66874’;

delete from sys.pending_sessions$ where local_tran_id = ‘1.92.66874’;

delete from sys.pending_sub_sessions$ where local_tran_id = ‘1.92.66874’;

commit;

Case:2 Distributed transaction without corresponding dba_2pc entries

====================================================================

In this case dba_2pc views are empty but users are receiving distributed txnrelated errors, e.g. ORA-2054, ORA-1591. Normally such a case should not appearand if it is reproducible a bug should be filed. Here is the list of severalalternative solutions that can be used in this case:

a. Perform incomplete recovery

b. Truncate the objects referenced by that transaction and import them

c. Use _corrupted_rollback_segments parameter to drop that rollback segment

d. Insert dummy entries into dba_2pc views and either commit or rollback force the distributed transaction

We will discuss only solution (d) here, as first 3 solutions can be found on Backup/Recovery Guide.

In the 4th solution a dummy entry is inserted intothe dictionary so that the transaction can be manually committed or rolled back.

Note that RECO will not be able to process this txn and distributed txn recovery should be disabled before using this method. Furthermore, please take a BACKUPof your database before using this method.The following example describes how to diagnose and resolve this case. Supposethat users are receiving

ORA-1591: lock held by in-doubt distributed transaction 1.92.66874

and the following query returns no rows:

SQL> select local_tran_id, state from dba_2pc_pending where local_tran_id=’1.92.66874′;

no rows selected

Furthermore querying the rollback segment shows that 1.92.66874 remains in prepared state,

SELECT KTUXEUSN, KTUXESLT, KTUXESQN, /* Transaction ID */

KTUXESTA Status,

KTUXECFL Flags

FROM x$ktuxe

WHERE ktuxesta!=’INACTIVE’

AND ktuxeusn= 1; /* <== Replace this value with your txn undo seg#
Which is displayed in the first part of

the transaction ID */

KTUXEUSN KTUXESLT KTUXESQN STATUS FLAGS

———- ———- ———- —————- ————————

1 92 66874 PREPARED SCO|COL|REV|DEAD

Trying to manually commit or rollback this transaction,

SQl> commit force ‘1.92.66874’;

ORA-02058: no prepared transaction found with ID 1.92.66874

raises ORA-02058 since dba_2pc views are empty. In order to use commit force or rollback force a dummy record should be inserted into pending_trans$ as follows:

alter system disable distributed recovery;

insert into pending_trans$ (

LOCAL_TRAN_ID,

GLOBAL_TRAN_FMT,

GLOBAL_ORACLE_ID,

STATE,

STATUS,

SESSION_VECTOR,

RECO_VECTOR,

TYPE#,

FAIL_TIME,

RECO_TIME)

values( ‘1.92.66874’, /* <== Replace this with your local tran id */
306206, /* */

‘XXXXXXX.12345.1.2.3’, /* These values can be used without any */

‘prepared’,’P’, /* modification. Most of the values are */

hextoraw( ‘00000001’ ), /* constant. */

hextoraw( ‘00000000’ ), /* */

0, sysdate, sysdate );

insert into pending_sessions$

values( ‘1.92.66874’,/* <==Replace only this with your local tran id */
1, hextoraw(‘05004F003A1500000104’),

‘C’, 0, 30258592, ”,

146

);

commit;

commit force ‘1.92.66874’

If commit force raises an error then note the errormessage and execute the following:

delete from pending_trans$ where local_tran_id=’1.92.66874′;

delete from pending_sessions$ where local_tran_id=’1.92.66874′;

commit;

alter system enable distributed recovery;

Otherwise run purge the dummy entry from the dictionary, using

alter system enable distributed recovery;

connect / as sysdba

COMMIT;

alter system set “_smu_debug_mode” = 4; /* if automatic undo management is being used */

commit; /* this is to prevent the ORA-01453 in purge_lost_db_entry call */

exec dbms_transaction.purge_lost_db_entry( ‘1.92.66874’ )

Case:3 How to PURGE the DISTRIBUTED transaction in PREPARED state, when COMMITor ROLLBACK FORCE hangs ?, where we have entries for both Distributedtransaction and dba_2pc entries.

==========================================================================

ISSUE DESCRIPTION

=================

ORA-01591: lock held by in-doubt distributed transaction 44.88.85589 The row exist from dba_2pc_pending & Rollback segment.

SQL> SELECT LOCAL_TRAN_ID,STATE FROM DBA_2PC_PENDING;

LOCAL_TRAN_ID STATE

—————– ———–

44.88.85589 prepared

SQL> SELECT KTUXEUSN, KTUXESLT, KTUXESQN, /* Transaction ID */

KTUXESTA Status,

KTUXECFL Flags

FROM x$ktuxe

WHERE ktuxesta!=’INACTIVE’

AND ktuxeusn= 44; /* <== Replace this value with your txn undo seg#
Which is displayed in the first part of

the transaction ID */

KTUXEUSN KTUXESLT KTUXESQN STATUS FLAGS

———- ———- ———- —————- ————————

44 88 85589 PREPARED SCO|COL|REV|DEAD

SQL> Commit force 44.88.85589;

SQL> rollback force 44.88.85589;

Executing COMMIT or ROLLBACK FORCE hangs

The wait event is “”free global transaction table entry”

Purging the transaction should fail with below error:

EXECUTE DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY(‘44.88.85589’);

BEGIN DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY(‘44.88.85589’); END;

*

ERROR at line 1:

ORA-06510: PL/SQL: unhandled user-defined exception

ORA-06512: at “SYS.DBMS_TRANSACTION”, line 94

ORA-06512: at line 1

Solution:

——–

You have to implement both the solution :

2.1 Dba_2pc entries without a corresponding transaction

2.2 Distributed transaction without corresponding dba_2pc entries

1.

delete from sys.pending_trans$ where local_tran_id = ‘44.88.85589’;

delete from sys.pending_sessions$ where local_tran_id = ‘44.88.85589’;

delete from sys.pending_sub_sessions$ where local_tran_id =’44.88.85589′;

commit;

2. Now insert the dummy record as explained in section:

2.2 Distributed transaction without corresponding dba_2pc entries

commit;

3. Commit force ‘44.88.85589’

4. Purge the transaction:

exec dbms_transaction.purge_lost_db_entry(‘44.88.85589’);

Metalink Noteid: How To Resolve Stranded DBA_2PC_PENDING Entries [ID 401302.1]

Oracle, SQL scripts

Post navigation

Previous Post: grep multuple patterns
Next Post: Processes Parameter decision

Related Posts

  • ORACLE_SID in sqlplus Oracle
  • Changing Instance Name ( No DB_NAME) Oracle
  • PLSQL Table Syntax 2 Oracle
  • Important Script Method for tuning Oracle
  • Standby Database Behavior when a Datafile is Resized on the Primary Database Note:123883.1 Oracle
  • Ports used by Oracle Software Oracle

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Ansible (0)
  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • MYSQL (5)
  • Oracle (393)
  • PHP/MYSQL/Wordpress (10)
  • POSTGRESQL (0)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (342)
  • SQL Server (6)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • Trace a SQL session from another session using ORADEBUG30-Sep-2025
  • SQL Server Vs Oracle Architecture difference25-Jul-2025
  • SQL Server: How to see historical transactions25-Jul-2025
  • SQL Server: How to see current transactions or requests25-Jul-2025
  • T-SQL Vs PL/SQL Syntax25-Jul-2025
  • Check SQL Server edition25-Jul-2025
  • Checking SQL Server Version25-Jul-2025
  • Oracle vs MYSQL Architecture differences (For DBAs)24-Jul-2025
  • V$INSTANCE of Oracle in MYSQL24-Jul-2025
  • Day to day MYSQL DBA operations (Compared with Oracle DBA)24-Jul-2025

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • find_du.ksh to find # of files, their sizes in current folder and its subdolder Linux/Unix
  • ORA-01220 Oracle
  • How To Limit The Access To The Database So That Only One User Per Schema Are Connected (One Concurrent User Per Schema) Oracle
  • logminer and my_lbu Oracle
  • VIvek Encryption Package and Its Usage Oracle
  • Check_recovery.sh program to run sqlplus and return its values remotely. Linux/Unix
  • dbinv.sql Oracle
  • Find_planinfo.sql Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme