現象描述:
(1).數據庫通過
調用透明網絡實現分布式事務,但透明網關停用后,失敗的分布式事務並未清理。
(2).數據庫 alert 日志
Thu Sep 06 06:53:00 2018
Errors in file /u01/app/oracle/diag/rdbms/zszdb/ZSZDB/trace/ZSZDB_reco_12245.trc:
ORA-01017: invalid username/password; logon denied
[Oracle][ODBC SQL Server Wire Protocol driver][SQL Server] 'RECOVER' ʧ {28000,NativeErr = 18456}
ORA-02063: preceding 2 lines from MSQL
(3).數據庫 RECO 進程 trc 日志
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1
System name: Linux
Node name: zszdb
Release: 2.6.27.19-5-default
Version: #1 SMP 2009-02-28 04:40:21 +0100
Machine: x86_64
Instance name: ZSZDB
Redo thread mounted by this instance: 1
Oracle process number: 19
Unix process pid: 12245, image: oracle@zszdb (RECO)
*** 2018-09-06 06:06:59.158
*** SESSION ID:(325.1) 2018-09-06 06:06:59.158
*** CLIENT ID:() 2018-09-06 06:06:59.158
*** SERVICE NAME:(SYS$BACKGROUND) 2018-09-06 06:06:59.158
*** MODULE NAME:() 2018-09-06 06:06:59.158
*** ACTION NAME:() 2018-09-06 06:06:59.158
ERROR, tran=9.13.220456, session#=1, ose=0:
ORA-01017: invalid username/password; logon denied
[Oracle][ODBC SQL Server Wire Protocol driver][SQL Server] 'RECOVER' ʧ {28000,NativeErr = 18456}
ORA-02063: preceding 2 lines from MSQL
故障原因:
Or
a
cle 數據庫中,RECO 進程用於自動地解決分布式事務發生錯誤的情況。一個節點上的 RECO 進程將會自動連接至存在 in-doubt 分布式事務的數據庫上。當 RECO 進程建立了數據庫連接后,它將會自動解決處於 in-dount 狀態的分布式事務,並將解決后的事務從 pending transation 表中刪除。
(
In a
distributed database
, the
RECO)
automatically resolves failures in
distributed transactions
. The RECO
process of a node automatically connects to other databases involved in an in-doubt distributed transaction. When RECO
reestablishes a connection between the databases, it automatically resolves all in-doubt transactions, removing from each database's pending transaction table any rows that correspond to the resolved transactions.)
故障場景中,數據庫通過調用透明網絡實現分布式事務,但
透明網關停用后,失敗的分布式事務並未清理。
例如:分布式事務於 PREPARE PHASE 階段出現異常。
則在本地端查詢 SQL>
select local_tran_id,state from dba_2pc_pending; 可得類似如下結果:
LOCAL_TRAN_ID STATE
---------------------- ----------------
2.12.64845 collecting
在遠端查詢 SQL>
select local_tran_id,state from dba_2pc_pending; 可得類似如下結果:
no rows selected
即表示本地數據庫要求其他點做好 commit 或者 rollback 准備,現在正在“收集”其他點的數據庫的返回信息,但是此時出現了錯誤,遠端數據庫未知狀態(in doubt)。
而 RECO 進程不斷自動處理無法解決的分布式事務,因此在數據庫 alert.log 日志中不斷報錯。
故障處理步驟:
為防止 RECO 進程不斷自動處理無法解決的分布式事務,需要將本地端的全局協調者(Global Coordinator)的 pending transation 清除掉。
依照上述例子的場景,分布式事務於 PREPARE PHASE 階段出現異常。因此,需要以 SYS 用戶登錄本地端數據庫,執行如下清理命令。
SQL>
execute DBMS_TRANSACTION.PURGE_LOST_DB_ENTRY('
local_tran_id
');
其中,
local_tran_id
為本地端的事務 ID。
參考文檔:
(1).http://blog.sina.com.cn/s/blog_6cfadffb0100m48t.html