deadlock detected

298 views
Skip to first unread message

albert vallès 2

unread,
May 4, 2012, 10:23:53 AM5/4/12
to h2-da...@googlegroups.com, albert. valles
Hi,

Having 3 threads running (one java swing application and two quartz jobs) with this h2 config:

hibernate.dialect=com.scytl.edmpb.H2.H2Dialect
db.driver=org.h2.Driver
db.host=tcp://localhost
db.tcpServer=-tcpAllowOthers
db.options=MAX_MEMORY_UNDO=20000;MAX_OPERATION_MEMORY=20000;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;IFEXISTS=TRUE;TRACE_LEVEL_FILE=3

and this hibernate config:

org.springframework.orm.hibernate3.LocalSessionFactoryBean
org.springframework.orm.hibernate3.HibernateTransactionManager
PROPAGATION_NEVER,ISOLATION_READ_UNCOMMITTED
<prop key="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_structured_entries">true</prop>

we get this java exception (attached more details):

org.h2.jdbc.JdbcSQLException: Deadlock detected. The current transaction was rolled back. Details: "
Session #1796 (user: SA) is waiting to lock PUBLIC.PACKAGE_VAULT while locking PUBLIC.BALLOTBOX (exclusive), PUBLIC.HISTORY_QUEUE (exclusive), PUBLIC.BALLOTBOX_SELECTION (exclusive).
Session #1797 (user: SA) is waiting to lock PUBLIC.HISTORY_QUEUE while locking PUBLIC.PACKAGE_VAULT (exclusive), PUBLIC.OUTGOING_QUEUE (exclusive)."; SQL statement:
insert into HISTORY_QUEUE (QUEUE_INSERT_TIME, CONTENT, QUEUE_POSITION) values (?, ?, ?) [40001-160]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.table.RegularTable.doLock(RegularTable.java:488)
at org.h2.table.RegularTable.lock(RegularTable.java:434)
at org.h2.command.dml.Insert.insertRows(Insert.java:123)
at org.h2.command.dml.Insert.update(Insert.java:84)
at org.h2.command.CommandContainer.update(CommandContainer.java:73)
at org.h2.command.Command.executeUpdate(Command.java:219)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:300)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:137)
at java.lang.Thread.run(Unknown Source)
at org.h2.engine.SessionRemote.done(SessionRemote.java:538)
at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:183)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:143)
at org.h2.jdbc.JdbcPreparedStatement.executeBatch(JdbcPreparedStatement.java:1092)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)

attached generated h2 trace.db

using MVCC we get a org.h2.jdbc.JdbcSQLException: Timeout trying to lock table


any ideas? LOCK_MODE? lock tables always in the same order? hibernate configuration? ...?

thanks in advance!
deadlock.log
deadlock-trace.db

Thomas Mueller

unread,
May 9, 2012, 2:43:54 AM5/9/12
to h2-da...@googlegroups.com
Hi,

If it's a deadlock, I guess you didn't lock the tables in the same order. I suggest to use SELECT ... FOR UPDATE. But I can't solve the problem for you, sorry.

Regards,
Thomas

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/HcUj-EgSF-0J.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
Reply all
Reply to author
Forward
0 new messages