sexta-feira, 13 de janeiro de 2012

ORA-01591: lock held by in-doubt distributed transaction string

Me deparei com esse erro em um cliente e fui pesquisar, encontrei isso:

http://ora-01591.ora-code.com/
ORA-01591:
lock held by in-doubt distributed transaction string
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.

Pesquisando um pouco mais, achei isso: http://www.vivaolinux.com.br/dica/Erro-de-Lock-ORA01591

Fui colocar em prática e não é que funcionou, vejam:

10:05:55 #fabalves@bd_teste _> Select * From sys.pending_trans$ Order by local_tran_id
10:06:16 2 ;

LOCAL_TRAN_ID GLOBAL_TRAN_FMT GLOBAL_ORACLE_ID GLOBAL_FOREIGN_ID
TRAN_COMMENT
STATE S H SESSION_ RECO_VEC TYPE# FAIL_TIME HEURISTIC RECO_TIME TOP_DB_USER TOP_O
S_USER TOP_OS_HOST
---------------------- --------------- ---------------------------------------------------------------- ------------------------------------------------------------------------------------------
-------------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------- ---------------- - - -------- -------- --------------- --------- --------- --------- --------
---------------------- ---------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------
----------------------
TOP_OS_TERMINAL
GLOBAL_COMMIT# SPARE1 SPARE2 SPARE3 SPARE4
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------- ---------------- --------------- ------------------------------ --------------- ------------------------------
7.13.730415 306206 fabalves.fc..tst.6b539243.7.13.730415 N/A
N/A
prepared P 00000001 00000001 0 13-JAN-12 N/A 13-JAN-12 AVINEW_RAN
roliveira fc\fcc-01010
fcc-01010
105769835858 N/A N/A N/A N/A


1 row selected.

--Forcçando o rollback
10:12:13 #fabalves@bd_teste _> rollback force '7.13.730415';

Rollback complete.

Elapsed: 00:00:02.91

--executando a query, o campo state mudou:
10:25:55 #fabalves@bd_teste _> @vtp

LOCAL_TRAN_ID GLOBAL_TRAN_FMT GLOBAL_ORACLE_ID
---------------------- --------------- ----------------------------------------------------------------
GLOBAL_FOREIGN_ID
------------------------------------------------------------------------------------------------------------------------
TRAN_COMMENT
------------------------------------------------------------------------------------------------------------------------
STATE S H SESSION_ RECO_VEC TYPE# FAIL_TIME HEURISTIC RECO_TIME TOP_DB_USER
---------------- - - -------- -------- --------------- --------- --------- --------- ------------------------------
TOP_OS_USER
----------------------------------------------------------------
TOP_OS_HOST
------------------------------------------------------------------------------------------------------------------------
TOP_OS_TERMINAL
------------------------------------------------------------------------------------------------------------------------
GLOBAL_COMMIT# SPARE1 SPARE2 SPARE3 SPARE4
---------------- --------------- ------------------------------ --------------- ------------------------------
7.13.730415 306206 fabalves.fc..tst.6b539243.7.13.730415
N/A
N/A
forced rollback P 00000001 00000001 0 13-JAN-12 13-JAN-12 13-JAN-12 AVINEW_RAN
roliveira
fc\fcc-01010
fcc-01010
105769835858 N/A N/A N/A N/A

--como sys, executando a limpeza dessa view
exec dbms_transaction.purge_lost_db_entry( '7.13.730415');

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.58
@vtp --ver transações pendentes

no rows selected


Mais uma aprendida

Nenhum comentário:

Postar um comentário