Timeout trying to lock... [HYT00-50]

70 views
Skip to first unread message

Thomas Wiradikusuma

unread,
Dec 19, 2007, 3:20:54 AM12/19/07
to H2 Database
hello guys,
i'm experiencing this exception everytime I want to remove/save row.

org.h2.jdbc.JdbcBatchUpdateException: Timeout trying to lock table
CONTENTASSETRESPONSE [HYT00-50]
at
org.h2.jdbc.JdbcPreparedStatement.executeBatch(JdbcPreparedStatement.java:
1040)
at
org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:
297)
at
org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:
297)
at
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:
48)
at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:
242)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:
235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:
139)
at
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:
298)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:
27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:
106)
at
org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:
578)
at
org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:
662)
at
org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:
632)
at
org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:
314)
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:
116)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:
171)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:
204)


if I do this in sequence (assuming the record/row is there), I'm using
Hibernate:
- load from DB
- change some value in the object (ex. obj.setName("thomas"))
- remove from DB
everything is OK

but if I create n threads (each thread handle different object <--
from different row),
the expection happens, and the rows are not deleted BUT the data is
changed (contents of "name" changed to "thomas").

i use Hibernate/Spring transaction support, Isolation read
uncommitted, auto-commit.

any hint? thx in advance.

regards,
Thomas Wiradikusuma

Thomas Mueller

unread,
Dec 22, 2007, 4:29:24 AM12/22/07
to h2-da...@googlegroups.com
Hi,

According to the exception code (-50) you are using version 1.0.50 from 2007-06-17. You should consider using a newer version. In newer versions, read committed is the default isolation level (like in most other databases). With older versions (including the version you are using), the default isolation level is serializable, where such scenarios can easily lead to lock timeout.

Regards,
Thomas


       at org.hibernate.impl.SessionImpl.managedFlush (SessionImpl.java:338)

Thomas Mueller

unread,
Dec 22, 2007, 4:32:17 AM12/22/07
to h2-da...@googlegroups.com
Hi,

I just read:

> Isolation read uncommitted

I don't think this isolation level is really in use, because in this mode lock timeouts can not happen (as far as I know).

Regards,
Thomas

Thomas Wiradikusuma

unread,
Dec 22, 2007, 6:27:58 AM12/22/07
to h2-da...@googlegroups.com
Exactly. That's why I'm confused. FYI I'm using Spring's
@Transactional. The same code works OK in MySQL.

A possible bug in H2?

Regards,
Thomas


--
salam hangat,
Thomas Wiradikusuma
http://wiradikusuma.blogspot.com/ <-- Tidak putih, tidak dapat cinta sejati

Thomas Mueller

unread,
Dec 26, 2007, 11:43:05 AM12/26/07
to h2-da...@googlegroups.com
Hi,


> A possible bug in H2?

I don't think so. Did you get my first response? Here again:


According to the exception code (-50) you are using version 1.0.50 from 2007-06-17. You should consider using a newer version. In newer versions, read committed is the default isolation level (like in most other databases). With older versions (including the version you are using), the default isolation level is serializable, where such scenarios can easily lead to lock timeout.

Regards,
Thomas

Thomas Wiradikusuma

unread,
Dec 26, 2007, 10:52:57 PM12/26/07
to h2-da...@googlegroups.com
aarrrrgghhhh.... it keeps happening!!!

I have used the most recent version (1.0.63) but the following
exception keep filling the log file:

Caused by: org.h2.jdbc.JdbcBatchUpdateException: Timeout trying to
lock table CONTENTASSETRESPONSE [HYT00-50]
at org.h2.jdbc.JdbcPreparedStatement.executeBatch(JdbcPreparedStatement.java:1040)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)


at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)

... 36 more

I don't encounter the exception if I do things very slow (one by one),
but once I stress test my app (using JMeter, 1000hits), it throws the
exception. using MySQL everything is OK (I only changed driver and
DB-connection configuration).

anyway, Merry Christmas :-)

On Dec 26, 2007 11:43 PM, Thomas Mueller <thomas.to...@gmail.com> wrote:
> Hi,
>
>
> > A possible bug in H2?
>
> I don't think so. Did you get my first response? Here again:
>
>
> According to the exception code (-50) you are using version 1.0.50 from
> 2007-06-17. You should consider using a newer version. In newer versions,
> read committed is the default isolation level (like in most other
> databases). With older versions (including the version you are using), the
> default isolation level is serializable, where such scenarios can easily
> lead to lock timeout.


--
regards,
Thomas Wiradikusuma

Thomas Wiradikusuma

unread,
Dec 26, 2007, 11:23:45 PM12/26/07
to h2-da...@googlegroups.com
how do I enable row level locking in H2? probably it's because the
locking level.


On Dec 27, 2007 10:52 AM, Thomas Wiradikusuma <wiradi...@gmail.com> wrote:
> aarrrrgghhhh.... it keeps happening!!!
>
> I have used the most recent version (1.0.63) but the following
> exception keep filling the log file:

--
regards,
Thomas Wiradikusuma

Thomas Mueller

unread,
Dec 28, 2007, 11:06:14 AM12/28/07
to h2-da...@googlegroups.com
Hi,

> I have used the most recent version (1.0.63) but the following
> exception keep filling the log file:
> Caused by: org.h2.jdbc.JdbcBatchUpdateException: Timeout trying to
> lock table CONTENTASSETRESPONSE [HYT00-50]
> at org.h2.jdbc.JdbcPreparedStatement.executeBatch(JdbcPreparedStatement.java:1040)
> at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
> at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
> at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)

The exception code 'HYT00-50' means you are using version 1.0.50. If
you are using version 1.0.63, then the exception code would be
HYT00-63. Could you check that the old version of H2 is not in the
classpath?

> how do I enable row level locking in H2? probably it's because the locking level.

I don't think that is the problem, but H2 does not yet support row
level locking. It does support multi version concurrency as an option
by the way, but this feature is quite new.

Happy New Year!

Regards,
Thomas

Thomas Wiradikusuma

unread,
Dec 28, 2007, 12:14:46 PM12/28/07
to h2-da...@googlegroups.com
On Dec 28, 2007 11:06 PM, Thomas Mueller <thomas.to...@gmail.com> wrote:
> The exception code 'HYT00-50' means you are using version 1.0.50. If
> you are using version 1.0.63, then the exception code would be
> HYT00-63. Could you check that the old version of H2 is not in the
> classpath?

arrrrgggghhhhhh.... you're right, i forget to clean!

thank you very much thomas, sorry for being stupid :-D

btw, thanks to h2, i can reach 200tps (mysql 100tps).

--
regards,
Thomas Wiradikusuma

Reply all
Reply to author
Forward
0 new messages