TA的每日心情 | 开心 2023-8-9 11:05 |
---|
|
楼主 |
发表于 2023-12-31 09:46:51
|
显示全部楼层
How to Check the User and the SQL text (DML) of an In-doubt Distributed Transaction found in dba_2pc_pending (Doc ID 1327159.1)
Having the transaction_id of the in-doubt transaction and the corresponding COMMIT# from DBA_2PC_PENDING , use Logminer to examine the online redo log(s) or the archived redo log(s) where the transaction is in , to determine the user name and the SQL text.
Example:
SQL> show user
USER is "SYS"
SQL> select local_tran_id, commit#, state
2 from DBA_2PC_PENDING;
LOCAL_TRAN_ID COMMIT# STATE
---------------------- ---------------- ----------------
1.16.942 1585840 prepared
SQL>
With the COMMIT# , check whether the transaction is in Online Redo logs (query V$LOG and V$LOGFILE) or in Archived Red logs (query V$ARCHIVED_LOG)
Online Redo:
SQL> select a.thread#, a.sequence#, b.member
2 from v$log a, v$logfile b
3 where a.group# = b.group# and
4 1585840 between a.FIRST_CHANGE# and a.NEXT_CHANGE#;
THREAD# SEQUENCE#
---------- ----------
MEMBER
--------------------------------------------------------------------------------
1 55
/bugmnt3/am/celcaix4/app/oracle/oradata/TARJP/redo01.log
Archived Redo:
SQL> select thread#, sequence#, name
2 from v$archived_log
3 where 1585840 between FIRST_CHANGE# and NEXT_CHANGE#;
THREAD# SEQUENCE#
---------- ----------
NAME
--------------------------------------------------------------------------------
1 55
/bugmnt3/am/celcaix4/app/oracle/product/11.2.0.4.0/dbs/arch1_55_937607111.dbf
Now user Logminer to examine the redo, for example:
SQL> show user
USER is "SYS"
SQL> exec dbms_logmnr.add_logfile('/bugmnt3/am/celcaix4/app/oracle/product/11.2.0.4.0/dbs/arch1_55_937607111.dbf');
PL/SQL procedure successfully completed.
SQL> EXECUTE DBMS_LOGMNR.START_LOGMNR (OPTIONS => DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG);
PL/SQL procedure successfully completed.
SQL> select OPERATION, TABLE_NAME, SQL_REDO, USERNAME
2 from V$LOGMNR_CONTENTS
3 where XIDUSN=1 and
4 XIDSLT = 16 and
5 XIDSQN=942 order by SCN asc;
OPERATION TABLE_NAME
-------------------------------- --------------------------------
SQL_REDO
--------------------------------------------------------------------------------
USERNAME
------------------------------
START
set transaction read write;
SCOTT
INSERT EMP
insert into "SCOTT"."EMP"("EMPNO","ENAME","JOB","MGR","HIREDATE","SAL","COMM","DEPTNO") values ('1041','MULDER',NULL,NULL,NULL,NULL,NULL,'10');
SCOTT
INTERNAL
SCOTT
INTERNAL
SCOTT
SQL>
As seen above, the in-doubt transaction 1.16.942 was executed by SCOTT and was an INSERT into SCOTT.DEPT
|
|