Reputation: 67
I have dead lock: sql A is waiting on sql B.
A is: delete from attachment where ID=:1
B is: delete from detail where ID=:1
Upvotes: 0
Views: 169
Reputation: 1547
I'd advise care with the terminology used: "Deadlock" has a very specific meaning (below) and what you are implying in your problem description is a "blocking lock".
A deadlock is the classic “deadly embrace” problem. The “deadly embrace” happens when, say Task B, attempts to lock a row which is being held by another task, say Task A, and Task A is waiting for Task B to release a lock. Oracle will abort one of the transaction to prevent a perpetual wait condition.
Root Cause (general): • Transactions deadlocked one another while waiting for resources. [from ora docs]
General Solution: • Generally, this is a design flaw in the application. • The deadlock is an application issue and must be fixed within the application; there is no DB fix for a deadlock.
A deadlock will result in Oracle terminating one of the sessions and that session will receive an error indicating the reason. This happens with 2 to 3 seconds of it being detected.
A blocking lock on the other hand will remain indefinitely until the blocking session either commits, is rolled-back or is killed (which does a rollback).
Also, check for cascading operations generated as recursive SQL by the DBMS.
Upvotes: 1