Replicating ORA-00060: deadlock detected while waiting for resource

I am trying to replicate an issue we recently faced. We have a PL/SQL procedure that has the logic below:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>procedure mark_records (p_request_id number)
is
begin
-- this marks which contracts are going to be processed
update jisip_agreements jp
set jp.request_id = p_request_id
where exists (select 1 from
jisip_eligible_transactions x
jisip_eligible_suppliers y
jisip_eligible_schedules z
where x.schedule_id = z.schedule_id
and y.supplier_id = x.supplier_id
and jp.agreement_id = y.agreement_id);
-- additional processing --
-- this unmarks the contracts were already processed
update jisip_agreements
set request_id = null
where request_id = p_request_id;
end;
/
</code>
<code>procedure mark_records (p_request_id number) is begin -- this marks which contracts are going to be processed update jisip_agreements jp set jp.request_id = p_request_id where exists (select 1 from jisip_eligible_transactions x jisip_eligible_suppliers y jisip_eligible_schedules z where x.schedule_id = z.schedule_id and y.supplier_id = x.supplier_id and jp.agreement_id = y.agreement_id); -- additional processing -- -- this unmarks the contracts were already processed update jisip_agreements set request_id = null where request_id = p_request_id; end; / </code>
procedure mark_records (p_request_id number)
is
begin
    
    -- this marks which contracts are going to be processed
    update  jisip_agreements jp
    set     jp.request_id = p_request_id
    where exists (select 1 from
                    jisip_eligible_transactions x
                    jisip_eligible_suppliers y
                    jisip_eligible_schedules z
                    where x.schedule_id = z.schedule_id 
                    and y.supplier_id = x.supplier_id
                    and jp.agreement_id = y.agreement_id);
    
    -- additional processing --

    -- this unmarks the contracts were already processed        
    update  jisip_agreements
    set     request_id = null
    where   request_id = p_request_id;
    

end;
/

This program basically “marks” those records in jisip_agreements to be processed, does some additional processing (i.e. inserts into table X), then later on those same records will be “unmarked” once processing is completed.

One of our clients is running this process 6-10 times simultaneously and concurrently within an hour and is causing a ORA-00060 deadlock issue. We already have a fix in mind (i.e. Autonomous Transaction, additional filters, etc.), but we are unable to replicate the issue internally and it always completes successfully. We want to replicate it before moving the fix to Production.

I created a mock test in a local Database to replicate it, but in a slightly different approach:

Session 1:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>set serveroutput on;
begin
update jisip_agreements
set request_id = 345435345
where agreement_id = 1;
dbms_session.sleep(5);
update jisip_agreements
set request_id = 345435345
where agreement_id = 2;
end;
/
</code>
<code>set serveroutput on; begin update jisip_agreements set request_id = 345435345 where agreement_id = 1; dbms_session.sleep(5); update jisip_agreements set request_id = 345435345 where agreement_id = 2; end; / </code>
set serveroutput on;
begin
    
    update  jisip_agreements
    set     request_id = 345435345
    where   agreement_id = 1;    
    
    dbms_session.sleep(5);
    
    update  jisip_agreements
    set     request_id = 345435345
    where   agreement_id = 2;        
      
end;
/

Session 2

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>set serveroutput on;
begin
update jisip_agreements
set request_id = 12345
where agreement_id = 2;
dbms_session.sleep(5);
update jisip_agreements
set request_id = 12345
where agreement_id = 1;
end;
/
</code>
<code>set serveroutput on; begin update jisip_agreements set request_id = 12345 where agreement_id = 2; dbms_session.sleep(5); update jisip_agreements set request_id = 12345 where agreement_id = 1; end; / </code>
set serveroutput on;
begin
    
    update  jisip_agreements
    set     request_id = 12345
    where   agreement_id = 2;    
    
    dbms_session.sleep(5);
    
    update  jisip_agreements
    set     request_id = 12345
    where   agreement_id = 1;
    
end;
/

I am getting the expected error:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> Error report - ORA-00060: deadlock detected while waiting for resource
ORA-06512: at line 9
00060. 00000 - "deadlock detected while waiting for resource"
*Cause: Transactions deadlocked one another while waiting for resources.
*Action: Look at the trace file to see the transactions and resources
involved. Retry if necessary.
</code>
<code> Error report - ORA-00060: deadlock detected while waiting for resource ORA-06512: at line 9 00060. 00000 - "deadlock detected while waiting for resource" *Cause: Transactions deadlocked one another while waiting for resources. *Action: Look at the trace file to see the transactions and resources involved. Retry if necessary. </code>
 Error report - ORA-00060: deadlock detected while waiting for resource  
 ORA-06512: at line 9  
 00060. 00000 -  "deadlock detected while waiting for resource"  
 *Cause:    Transactions deadlocked one another while waiting for resources.  
 *Action:   Look at the trace file to see the transactions and resources  
            involved. Retry if necessary.

How can I replicate the ORA-0060 issue using the procedure?

10

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật