This content has been marked as final.
Show 1 reply
-
1. Re: Deadlock Exception
adrian.brock Jun 20, 2003 10:38 PM (in response to shmel)A deadlock is often caused by ordering problems
e.g.
Transaction1 lock A
Transaction2 lock B
Transaction1 A.tryToLockB()
Transaction2 B.tryToLockA()
Deadlock! Transaction1 holds A but wants B and
Transaction2 holds B but wants A.
Solutions:
1) Rearrange the access so that A is always before B
or B is always before A
2) The latest versions of JBoss will rollback transaction2
which introduced the deadlock and retry it.
3) Use read only access so that locks are maintained
for very long if that fits your locking requirement
4) Use optimistic locking and code for rollbacks.
Regards,
Adrian