------------------------------------------------------------------------------- -- -- Script: rolling_back.sql -- Purpose: to predict when transactions will finish rolling back -- For: 9.0+ -- -- Copyright: (c) Ixora Pty Ltd -- Author: Steve Adams -- ------------------------------------------------------------------------------- @save_sqlplus_settings set serveroutput on set feedback off prompt prompt Looking for transactions that are rolling back ... prompt declare cursor tx is select s.username, t.xidusn, t.xidslot, t.xidsqn, x.ktuxesiz from sys.x$ktuxe x, sys.v_$transaction t, sys.v_$session s where x.inst_id = userenv('Instance') and x.ktuxesta = 'ACTIVE' and x.ktuxesiz > 1 and t.xidusn = x.ktuxeusn and t.xidslot = x.ktuxeslt and t.xidsqn = x.ktuxesqn and s.saddr = t.ses_addr; user_name varchar2(30); xid_usn number; xid_slot number; xid_sqn number; used_ublk1 number; used_ublk2 number; begin open tx; loop fetch tx into user_name, xid_usn, xid_slot, xid_sqn, used_ublk1; exit when tx%notfound; if tx%rowcount = 1 then sys.dbms_lock.sleep(10); end if; select sum(ktuxesiz) into used_ublk2 from sys.x$ktuxe where inst_id = userenv('Instance') and ktuxeusn = xid_usn and ktuxeslt = xid_slot and ktuxesqn = xid_sqn and ktuxesta = 'ACTIVE'; if used_ublk2 < used_ublk1 then sys.dbms_output.put_line( user_name || '''s transaction ' || xid_usn || '.' || xid_slot || '.' || xid_sqn || ' will finish rolling back at approximately ' || to_char( sysdate + used_ublk2 / (used_ublk1 - used_ublk2) / 6 / 60 / 24, 'HH24:MI:SS DD-MON-YYYY' ) ); end if; end loop; if user_name is null then sys.dbms_output.put_line('No transactions appear to be rolling back.'); end if; end; / prompt @restore_sqlplus_settings
Script:when transaction will finish rollback
2007/04/19 by Leave a Comment
VIEW: X$KTUXE – Transaction Entry (table)
2007/04/19 by 1 Comment
View: X$KTUXE [K]ernel [T]ransaction [U]ndo Transa[x]tion [E]ntry (table) This view is very useful as it gives an indication of the state of the transaction tables in the rollback segment headers. The information here can be used to see the state of transactions requiring transaction recovery do not show in <View:V$TRANSACTION> <Event:10013> may be useful to trace transaction recovery. Column Type Description -------- ---- -------- ADDR RAW(4|8) address of this row/entry in the array or SGA INDX NUMBER index number of this row in the fixed table array INST_ID NUMBER 8.x oracle instance number Transaction ID KTUXEUSN NUMBER undo seg number KUSNOLTP UB2MAXVAL is no-undo xac KTUXESLT NUMBER slot number KSLTINV UB2MAXVAL not a valid slot num KTUXESQN NUMBER wrap number, is savept # at start if no-undo xac position within transaction KTUXERDBF NUMBER relative File KTUXERDBB NUMBER relative Block KTUXESCNB NUMBER SCN base for prepare/commit KTUXESCNW NUMBER SCN wrap for prepare/commit KTUXESTA VARCHAR2(16) Transaction Status KTUXECFL VARCHAR2(24) Transaction flags KTUXEUEL NUMBER Used for extent of tx and link to commit list Distributed tx: collecting dba and undo bk to start retrieving collecting info rec KTUXEDDBF NUMBER relative file KTUXEDDBB NUMBER relative dba Parent transaction id KTUXEPUSN NUMBER 8.x undo seg number KUSNOLTP UB2MAXVAL is no-undo xac KTUXEPSLT NUMBER 8.x slot number KSLTINV UB2MAXVAL not a valid slot num KTUXEPSQN NUMBER 8.x wrap number, is savept # at start if no-undo xac position within transaction KTUXESIZ NUMBER 8.1 number of undo blocks used by the transaction Notes: To see any DEAD transactions for deferred transaction recovery after startup: select * from x$ktuxe where ktuxecfl='DEAD';