google-code-export / h2database

Automatically exported from code.google.com/p/h2database
0 stars 1 forks source link

Java Level Deadlock on Database & Session Objects #315

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is the ticket for the discussed problem in 
http://groups.google.com/group/h2-database/browse_thread/thread/3c2eaa5e7b5bdefa
?hl=en .

The problem is a java deadlock scenario:  one thread tries to access a Database 
object, which is hold by the second thread, while having locked a Session 
object. The second thread tries to lock the very same Session object and is 
holding the lock on the same Database object.

(see picture of profiler stacktrace)

Annotated stack trace (by Noel Grandin):

Command#executeQuery which takes a lock on a Database object
JdbcPreparedStatement#executeQuery takes a lock on a Session object
LobStorage.LobInputStream#fillBuffer
LobStorage.LobInputStream#readFully
LobStorage.LobInputStream#read
IOUtils#copy
IOUtils#copy
IOUtils#copyAndCloseInput
Transfer#writeValue
TcpServerThread#sendRow

JdbcPreparedStatement#executeUpdateInternal takes a lock on a Session object
JdbcPreparedStatement#executeUpdate
LobStorage#setTable
ValueLobDb#link
PageDataIndex#add
RegularTable#addRow
Insert#insertRows
Insert#update
CommandContainer#update
Command#executeUpdate which takes a lock on a Database object

--------

Environment:
H2 1.3.154
Jackrabbit 2.2.4, H2 used only in context with stock DatabaseJournal
SUN JDK 1.6.0_24 64bit
Windows 2008 Server R2 64bit

--------

We have currently a workaround working with Apache Derby as the Cluster Journal 
but would prefer H2 :)

Original issue reported on code.google.com by tanju.er...@gmail.com on 19 Apr 2011 at 1:10

Attachments:

GoogleCodeExporter commented 9 years ago
I can reproduce the problem now with a simple test case.
This problem will be fixed in the next release.
Thanks a lot! 

Original comment by thomas.t...@gmail.com on 6 May 2011 at 8:54

GoogleCodeExporter commented 9 years ago
This is fixed in version 1.3.155

Original comment by thomas.t...@gmail.com on 27 May 2011 at 10:55

GoogleCodeExporter commented 9 years ago
Can you please provide the simpler test that reproduces this bug.
I'm working on a tool for detecting implementation bugs on in-memory db and I 
would really appreciate it.

Thanks.

Original comment by joao.soa...@gmail.com on 1 Jun 2011 at 9:34

GoogleCodeExporter commented 9 years ago
See http://code.google.com/p/h2database/source/detail?r=3603

Original comment by thomas.t...@gmail.com on 17 Jul 2011 at 8:57