ORA-01591: lock held by in-doubt distributed transaction問題解決,ora-01591in-doubt
昨天跑批量資料的程式時遇到oracle錯誤:
$tail -f INDB_ERROR_8.LOG
[Time]2014-12-01 04:10:31: activeAccountDeposit in oracle error: =ORA-01591: lock held by in-doubt distributed transaction 20.21.65527021
[Time]2014-12-01 04:10:31: 檔案:/billing/drecv4/drecvlog/201411/DRECV/tmp/8-15-accountdeposit.dat改名到/billing/drecv4/drecvlog/201411/DRECV/tmp/8-15-accountdeposit.dat.err失敗!ORA-01591: lock held by in-doubt distributed transaction 20.21.65527021
DwriteOffCore.cpp:3152
[Time]2014-12-01 04:10:31: 8-15-accountdeposit.dat更新表發生錯誤!ORA-01591: lock held by in-doubt distributed transaction 20.21.65527021
DwriteOffCore.cpp:4431
[Time]2014-12-01 04:10:31: 入庫發生錯誤!
重複跑程式錯誤依舊。
開啟資料庫,查看這個tran_id確實有,其實是11月19號的時候就留下了這個事務。這是分散式交易的問題,當執行這個事務的時候遇到一些問題,比如網路問題,oracle就會卡住在這裡,一直留著,當後面你更新到這條資料的時候就會報這個錯。
然後找dba,他執行一下:
rollback force ‘20.21.65527021’
commit
搞定。
後續防止這個錯誤的其中一個方法就是,在跑批配量序前,統一先檢查並殺掉這些阻塞。
附錄:
ORA-01591: "lock held by in-doubt distributed transaction %s"
Cause: Trying to access resource that is locked by a dead
two-phase commit transaction that is in prepared state.
Action: DBA should query the pending_trans$ and related tables,
and attempt to repair network connection(s) to
coordinator and commit point. If timely repair is not
possible, DBA should contact DBA at commit point if
known or end user for correct outcome, or use heuristic
default if given to issue a heuristic commit or abort
command to finalize the local portion of the
distributed transaction.