Subject Deadlock question
Author Dave Byrne
I am seeing two different types of deadlock exceptions. The first one
is due to concurrent modification of a record and happens when I run two
clients against the same database. The exception message says "
deadlock \n update conflicts with concurrent update". This one is
pretty clear, and is actually not a problem at all.



The second one happens everyone once in a while when I have a
multi-threaded client running against the database. *Every* time it
occurs, a SQL SELECT query is being executed (although there are
potentially other update operations in the transaction). The exception
message just says "deadlock". I could add instrumentation to see what
happened during the failed transaction, but what I would really like to
find out is, what happened during the conflicting transaction that was
allowed to succeed.



So my question is, what is the best way to debug something like this.
And also, is there any significance to the fact that the text of the
exception messages is different



Any help would be appreciated.



Thanks,



Dave





1.) Exception during update. This one I understand.



ERROR 09:53:46 util.JDBCExceptionReporter HIBERNATE - GDS Exception.
335544336. deadlock

update conflicts with concurrent update

ERROR 09:53:46 util.JDBCExceptionReporter HIBERNATE - could not update:
[com.pangonetworks.TestRecord#11395]

org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544336. deadlock

update conflicts with concurrent update

at
org.firebirdsql.jdbc.AbstractPreparedStatement.internalExecute(AbstractP
reparedStatement.java:503)

at
org.firebirdsql.jdbc.AbstractPreparedStatement.executeUpdate(AbstractPre
paredStatement.java:144)

at
net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.j
ava:22)

at
net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:6
89)

at
net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:6
42)

at
net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)

at
net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)

at
net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2368)

at
net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)

at
net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java
:61)

at
com.pangonetworks.common.data.session.hibernate.HibernateDatastoreSessio
n.commit(HibernateDatastoreSession.java:149)

at com.pangonetworks.Test2.writeRecord(Test2.java:233)

at

org.firebirdsql.gds.GDSException: deadlock

update conflicts with concurrent update

at
org.firebirdsql.jgds.GDS_Impl.readStatusVector(GDS_Impl.java:1816)

at
org.firebirdsql.jgds.GDS_Impl.receiveResponse(GDS_Impl.java:1769)

at
org.firebirdsql.jgds.GDS_Impl.isc_dsql_execute2(GDS_Impl.java:917)

at
org.firebirdsql.jca.FBManagedConnection.executeStatement(FBManagedConnec
tion.java:793)

at
org.firebirdsql.jdbc.AbstractConnection.executeStatement(AbstractConnect
ion.java:946)

at
org.firebirdsql.jdbc.AbstractPreparedStatement.internalExecute(AbstractP
reparedStatement.java:499)

at
org.firebirdsql.jdbc.AbstractPreparedStatement.executeUpdate(AbstractPre
paredStatement.java:144)

at
net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.j
ava:22)

at
net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:6
89)

at
net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:6
42)

at
net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)

at
net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)

at
net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2368)

at
net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)

at
net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java
:61)

at
com.pangonetworks.common.data.session.hibernate.HibernateDatastoreSessio
n.commit(HibernateDatastoreSession.java:149)

at com.pangonetworks.Test2.writeRecord(Test2.java:233)



2.) Deadlock exception during query. Not sure how to debug this.



ERROR 01:37:12 util.JDBCExceptionReporter HIBERNATE - GDS Exception.
335544336. deadlock

ERROR 01:37:12 util.JDBCExceptionReporter HIBERNATE - Could not execute
query

org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544336. deadlock

at
org.firebirdsql.jdbc.FBStatementFetcher.fetch(FBStatementFetcher.java:19
8)

at
org.firebirdsql.jdbc.FBStatementFetcher.next(FBStatementFetcher.java:110
)

at
org.firebirdsql.jdbc.FBResultSet.next(FBResultSet.java:223)

at net.sf.hibernate.loader.Loader.doQuery(Loader.java:200)

at
net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Lo
ader.java:133)

at net.sf.hibernate.loader.Loader.doList(Loader.java:955)

at net.sf.hibernate.loader.Loader.list(Loader.java:946)

at
net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:846)

at
net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)

at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)

at
com.pangonetworks.common.data.session.hibernate.HibernateDatastoreSessio
n$1.execute(HibernateDatastoreSession.java:269)

at
com.pangonetworks.common.data.session.hibernate.HibernateDatastoreSessio
n.executeTask(HibernateDatastoreSession.java:409)

at
com.pangonetworks.common.data.session.hibernate.HibernateDatastoreSessio
n.executeQuery(HibernateDatastoreSession.java:260)

at
com.pangonetworks.common.data.session.hibernate.HibernateDatastoreSessio
n.query(HibernateDatastoreSession.java:224)

at com.pangonetworks.Test.findRows(Test.java:97)

at

org.firebirdsql.gds.GDSException: deadlock

at
org.firebirdsql.jgds.GDS_Impl.readStatusVector(GDS_Impl.java:1816)

at
org.firebirdsql.jgds.GDS_Impl.receiveResponse(GDS_Impl.java:1769)

at
org.firebirdsql.jgds.GDS_Impl.isc_dsql_fetch(GDS_Impl.java:1106)

at
org.firebirdsql.jca.FBManagedConnection.fetch(FBManagedConnection.java:8
28)

at
org.firebirdsql.jdbc.AbstractConnection.fetch(AbstractConnection.java:96
9)

at
org.firebirdsql.jdbc.FBStatementFetcher.fetch(FBStatementFetcher.java:19
2)

at
org.firebirdsql.jdbc.FBStatementFetcher.next(FBStatementFetcher.java:110
)

at
org.firebirdsql.jdbc.FBResultSet.next(FBResultSet.java:223)

at net.sf.hibernate.loader.Loader.doQuery(Loader.java:200)

at
net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Lo
ader.java:133)

at net.sf.hibernate.loader.Loader.doList(Loader.java:955)

at net.sf.hibernate.loader.Loader.list(Loader.java:946)

at
net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:846)

at
net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)

at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)

at
com.pangonetworks.common.data.session.hibernate.HibernateDatastoreSessio
n$1.execute(HibernateDatastoreSession.java:269)

at
com.pangonetworks.common.data.session.hibernate.HibernateDatastoreSessio
n.executeTask(HibernateDatastoreSession.java:409)

at
com.pangonetworks.common.data.session.hibernate.HibernateDatastoreSessio
n.executeQuery(HibernateDatastoreSession.java:260)

at
com.pangonetworks.common.data.session.hibernate.HibernateDatastoreSessio
n.query(HibernateDatastoreSession.java:224)

at com.pangonetworks.Test.findRows(Test.java:97)



[Non-text portions of this message have been removed]