Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

deadlock during execution of autonomous transaction block (having insert statement)

user-ir0yjApr 19 2023 — edited Apr 19 2023

In our production DB, deadlock was detected in database alert log/trace file. The trace file shows that the same session, process and serial # are locking each other out . The call stack and deadlock graph are shown below:

  1. It seems this situation happens when there is an unindexed foreign key involved. There is only one FK which is already indexed.
  2. The primary key of batch_detail_log is populated by a before insert trigger in batch_detail_log table using a sequence (with nocache/order) and there is a commit right after the insert. Does the commit rule out the possibility of a PK overlap during insert or it might be causing it?

Call Stack:

0x7f738778 3173 package body DBO.PKG_AUTONOMOUS_TRANS.P_CREATE_DETAIL_LOG

0xb588e990 3170 package body DBO.PKG_BENEFIT_WH.P_GENERATE_REPORT_CONTRIBUTION.P_INSERT_INTO_BATCH_DETAIL_LOG

0xb588e990 5847 package body DBO.PKG_BENEFIT_WH.P_GENERATE_REPORT_CONTRIBUTION

0xb588e990 6243 package body DBO.PKG_BENEFIT_WH.P_GENERATE_REPORT

0xa05b1648 93 procedure DBO.P_MODIFY_WR

0xbdff1d90 1 anonymous block

Deadlock graph:

Signature of procs and packages involved:

DBO.PKG_BENEFIT_WH.P_GENERATE_REPORT_CONTRIBUTION has a sub proc p_insert_into_batch_detail_log which is inserting into the detail log.

Signature:

PROCEDURE p_insert_into_batch_detail_log(…………….) IS
begin
dbo.pkg_autonomous_trans.p_create_detail_log(………..);

Signature of PKG_AUTONOMOUS_TRANS.P_CREATE_DETAIL_LOG:

procedure p_create_detail_log(………….) is
pragma autonomous_transaction;

BEGIN

insert into dbo.batch_detail_log…………..;

COMMIT;

What might be causing the deadlock? Can anybody please suggest a possible solution?

Thanks !!

Comments
Post Details
Added on Apr 19 2023
6 comments
1,004 views