image

编辑人: 流年絮语

calendar2025-04-29

message4

visits573

How to detect and cleanup pending transactions in Oracle?

Usually pending transactions clear up on their own. If not, read on.
If you have a pending transaction that will not go away then check the pending states with the following query:
SELECT local_tran_id, state, mixed
FROM dba_2pc_pending;
Pending transactions can be in any of the following states :
collecting, committed, prepared, forced commit, forced rollback
If the transaction is in the ‘prepared’ state then run
COMMIT FORCE ‘<local_tran_id>’;
or
ROLLBACK FORCE ‘<local_tran_id>’;
If the transaction is any state (other than ‘prepared’) and the transaction is not resolving then Log in as ‘SYS’ and run the following script
exec dbms_transaction.purge_lost_db_entry(<local_tran_id>);

Usually pending transactions clear up on their own. If not, read on.

If you have a pending transaction that will not go away then check the pending states with the following query:

SELECT local_tran_id, state, mixed

FROM dba_2pc_pending;

Pending transactions can be in any of the following states :

collecting, committed, prepared, forced commit, forced rollback

If the transaction is in the ‘prepared’ state then run

COMMIT FORCE ‘<local_tran_id>’;

or

ROLLBACK FORCE ‘<local_tran_id>’;

If the transaction is any state (other than ‘prepared’) and the transaction is not resolving then Log in as ‘SYS’ and run the following script

exec dbms_transaction.purge_lost_db_entry(<local_tran_id>);

喵呜刷题:让学习像火箭一样快速,快来微信扫码,体验免费刷题服务,开启你的学习加速器!

创作类型:
原创

本文链接:How to detect and cleanup pending transactions in Oracle?

版权声明:本站点所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明文章出处。
分享文章
share