Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use ROWLOCK with EJB
    primarykey
    data
    text
    <p>I have a problem where I get a deadlock on a MS SQL Server. The same code runs without problems on MySQL.</p> <p>My problem is that I receive a request to delete a job (which is attached to a device), and afterwards I receive a request to create a new job for the same device. Most times this works without any problems, but once in a while the delete request is not finished when I receive the request to create a new job for the device, and this is where I get the deadlock.</p> <p>The application is running on JBoss, and I receive the requests from a message queue.</p> <p>I have found out that I probably could solve the problem on MSSQL using the rowlock keyword, but how do I enable this when using named queries and at the same time supporting MySQL?</p> <p>Or are there any other way I could ensure that one request finishes before running the next request for the same device?</p> <p>A stacktrace with some parts removed looks like the following:</p> <pre><code>2009-08-11 10:03:22,621 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 1205, SQLState: 40001 2009-08-11 10:03:22,621 ERROR [org.hibernate.util.JDBCExceptionReporter] Transaction (Process ID 200) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. 2009-08-11 10:03:22,621 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session org.hibernate.exception.LockAcquisitionException: could not delete: [dme.dm.device.Task#131] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:82) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) ---cut cut cut--- Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Transaction (Process ID 200) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source) ---cut cut cut--- </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload