If a commit is happening after the entire cursor batch is updated, then it may just be a straight forward deadlocking scenario where the two cursors are operating on the same rows but in a different order.
- Assume
session 1
hascursor set 1
and is updatingrefs_code 1
andrefs_code 2
in that order before attempting a commit. - Assume
session 2
hascursor set 2
and is updatingrefs_code 2
andrefs_code 1
in that order before attempting a commit.
Then, interleaving the updates:
time cursor set 1 cursor set 2
==== ============ ============
t1 refs_code 1 -
t2 - refs_code 2
t3 refs_code 2 -
t4 - refs_code 1
at t3, cursor set 1
is waiting on cursor set 2
to commit refs_code 2
at t4, cursor set 2
is waiting on cursor set 1
to commit refs_code 1
The two transactions are waiting on different rowids. If that is the case, you may be able to add an order by
(in the same direction) to both cursors to help avoid this.