ORACLE二阶段锁问题

来源:互联网 发布:手机淘宝店铺店招尺寸 编辑:程序博客网 时间:2024/05/29 11:06

原文出处:http://blog.chinaunix.net/uid-22340094-id-88101.html


select  local_tran_id,
        nvl(global_oracle_id, global_tran_fmt||'.'||global_foreign_id),
        state, decode(status,'D','yes','no'), heuristic_dflt, tran_comment,
        fail_time, heuristic_time, reco_time,
        top_os_user, top_os_terminal, top_os_host, top_db_user, global_commit#
from    sys.pending_trans$


sqlplus "/as sysdba" <<!
set head off
set feedback off
set serveroutput off
set pagesize 0
set linesize 500
spool ss
select LOCAL_TRAN_ID from dba_2pc_pending;
spool off
!
cat ss.lst |awk '{printf "sqlplus \"/as sysdba\"<<! \nalter session set \"_smu_debug_mode\"=4;\nEXECUTE DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY('\'%s\'');\n!\n\n",$1,$1,$1}' >ttt
sh ttt
 
1、查找
select   GLOBAL_TRAN_ID   from     DBA_2PC_PENDING;  
2、强制提交或回滚
ROLLBACK   FORCE   '&GLOBAL_TRAN_ID';  
commit   froce   &GLOBAL_TRAN_ID';  

如:
rollback   force   '13.83.15198 ';

3、或者将事务对应的session杀掉[对应session]
select t.*,rowid from dba_2pc_pending@bcv_yyb1 t;select t.*,rowid from sys.pending_trans$ t;select t.*,rowid from sys.PENDING_SESSIONS$ t;
 
 
处理方式四种
 

A: Cleanup Steps: Before you begin, make note of the local transaction ID,, from the error message reported.
1. Determine if you want to attempt a commit or rollback of this transaction. You can do the following select to help determine what action to take:
SQL>; select state, advice from dba_2pc_pending where
local_tran_id = "";
2. Commit or rollback the transaction. To commit: SQL>; commit force ““; To rollback:
SQL>; rollback force ““;
3. If your are using release 7.3.x or greater and Step 1 above fails, execute the following command in either Server Manager or SQL*Plus: SQL>; execute dbms_transaction.purge_lost_db_entry(““);
NOTE: The purge_lost_db_entry function is fully documented in the "dbmsutil.sql" script located in the "$ORACLE_HOME/rdbms/admin" directory.
4. If running a release below 7.3 -OR- both Steps 1 and 2 above have failed, do the following: Connect to Server Manager or SQL*Plus and execute the following commands:
SQL>; set transaction use rollback segment system;
SQL>; delete from dba_2pc_pending where local_tran_id = ““;
SQL>; delete from pending_sessions$ where local_tran_id = ““;
SQL>; delete from pending_sub_sessions$ where local_tran_id = ““;
SQL>; commit;

0 0
原创粉丝点击