24756: transaction does not exist处理(2)

Scenario 1 local prepared ,remote commited

local:  
select local_tran_id,state from dba_2pc_pending;  
LOCAL_TRAN_ID   STATE  
6.22.290635   prepared  
remote DB:  
select local_tran_id,state from dba_2pc_pending;  
LOCAL_TRAN_ID   STATE  
1.92.66874   commited  

即表示远程数据库可能已经commit,但是本地数据库未知远程数据库的状态,还是处于prepared状态。我们需要如下处理:

local:  
commit force '6.22.290635';

exec DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY('6.22.290635');

 
remote DB:  

exec DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY('1.92.66874');

 

Scenario2  local commited,remote commited

local:  
select local_tran_id,state from dba_2pc_pending;  
LOCAL_TRAN_ID   STATE  
6.22.290635   commited  
remote DB:  
select local_tran_id,state from dba_2pc_pending;  
LOCAL_TRAN_ID   STATE  
1.92.66874   commited  

即表示本地和远程数据库均完成commit,但未清除分布式事务信息,我们需要如下处理:

local:  

exec DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY('6.22.290635');

 
remote DB:  

exec DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY('1.92.66874');

 

3.FORGET PHASE:
  3.1 参与的点通知commit point site他们已经完成commit,commit point site就能忘记(forget)这个事务。
  3.2 commit point site在远程数据库上清除分布式事务信息。
  3.3 commit point site通知Global Coordinator可以清除本地的分布式事务信息。
  3.4 Global Coordinator清除分布式事务信息。

local:

select local_tran_id,state from dba_2pc_pending;  
LOCAL_TRAN_ID   STATE  
6.22.290635   commited  

remote DB

select local_tran_id,state from dba_2pc_pending;  
no rows selected.  

即表示远端已完成commit,通知Global Coordinator清除分布式事务信息,但是本地没有收到该信息,我们改如下处理:

local  

exec DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY('6.22.290635');

 

总结分佈式事务的状态依次如下:

phase   local_state   remote_state   action  
prepare   collecting
prepared
  /
/
  本地DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY
本地rollback force后PURGE_LOST_DB_ENTRY
 
commit   prepared
commited
  commited
commited
  本地commit force后本地和远程均PURGE
本地和远程均PURGE_LOST_DB_ENTRY
 
forget   commited   /   本地PURGE_LOST_DB_ENTRY  

更多Oracle相关信息见Oracle 专题页面 ?tid=12

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5eb77577c740463d6e4e5b6d31f344e7.html