This discussion is archived
2 Replies Latest reply: Nov 14, 2012 6:27 AM by JamesSutherland RSS

how do i fix a deadlock issue

veenapandit Newbie
Currently Being Moderated
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-02049: timeout: distributed transaction waiting for lock

Error Code: 2049
     bind => [Saint Petersburg, 2012-11-09 08:16:03.058, 256808]
Query: UpdateObjectQuery(gov.samhsa.dasis.isats.model.model.FacilityAddresses@134c0a4)
     at org.eclipse.persistence.exceptions.DatabaseException.sqlException(
     at or

We need t o go to production soon, Please help
  • 1. Re: how do i fix a deadlock issue
    cdelahun Pro
    Currently Being Moderated
    The error doesn't really indicate a deadlock, just that it not obtain the lock before the transaction timed out. You need more information to determine why it is timing out, such as monitoring the load and other transactions that are occuring around that time period.

    If it is because the transaction is a long running process, you may need to up the transaction timeout value so that it can complete in time, or break up the transaction into smaller parts. If it is because of other long running transactions or load, increasing the timeout might make things worse if it allows requests to start piling up waiting rather than timing out. You'll need to figure out what is going wrong and tune your application and servers according to usage patterns.

    The Oracle TopLink documentation has some information and links on performance tuning here that might help:

    Best Regards,
  • 2. Re: how do i fix a deadlock issue
    JamesSutherland Pro
    Currently Being Moderated
    Are you sure it is a database deadlock? Do you have other threads that have locks on the same row?

    You could try setting the persistence unit property,


    This will make the row access order for updates consistent, which can avoid deadlocks.

    You could also consider using pessimistic locking for highly contended objects. If each thread locks the same object upfront before acquiring other locks, then the deadlock can be avoided.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points