尝试锁定h2中的表时发生超时错误 [英] Timeout error trying to lock table in h2
问题描述
在某些情况下,我会收到以下错误消息
I get the following error under a certain scenario
当一个不同的线程通过批量上传操作填充很多用户时,我试图在不同的网页上查看所有用户的列表.列表查询,引发以下超时错误.有没有一种方法可以设置此超时,以便我可以避免此超时错误.
When a different thread is populating a lot of users via the bulk upload operation and I was trying to view the list of all users on a different web page. The list query, throws the following timeout error. Is there a way to set this timeout so that I can avoid this timeout error.
Env:h2(最新),Hibernate 3.3.x
Env: h2 (latest), Hibernate 3.3.x
Caused by: org.h2.jdbc.JdbcSQLException: Timeout trying to lock table "USER"; SQL statement:
[50200-144]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.table.RegularTable.doLock(RegularTable.java:482)
at org.h2.table.RegularTable.lock(RegularTable.java:416)
at org.h2.table.TableFilter.lock(TableFilter.java:139)
at org.h2.command.dml.Select.queryWithoutCache(Select.java:571)
at org.h2.command.dml.Query.query(Query.java:257)
at org.h2.command.dml.Query.query(Query.java:227)
at org.h2.command.CommandContainer.query(CommandContainer.java:78)
at org.h2.command.Command.executeQuery(Command.java:132)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:278)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:137)
at java.lang.Thread.run(Thread.java:619)
at org.h2.engine.SessionRemote.done(SessionRemote.java:543)
at org.h2.command.CommandRemote.executeQuery(CommandRemote.java:152)
at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:96)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:342)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1808)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
... 125 more
推荐答案
是的,您可以更改锁定超时.默认值比较低:1秒(1000毫秒).
Yes, you can change the lock timeout. The default is relatively low: 1 second (1000 ms).
在许多情况下,问题在于另一个连接已锁定了表,并且使用多版本并发也可以解决该问题(将;MVCC=true
附加到数据库URL).
In many cases the problem is that another connection has locked the table, and using multi-version concurrency also solves the problem (append ;MVCC=true
to the database URL).
MVCC=true
参数不再受支持,因为 h2 1.4.200 对于MVStore引擎(这是默认引擎)总是如此.
MVCC=true
param is no longer supported, because since h2 1.4.200 it's always true for a MVStore engine, which is a default engine.
这篇关于尝试锁定h2中的表时发生超时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!