Deadlock, if two threads try to close an entity manager

#1

Hello,

we get into a deadlock, if two threads  try to close an entity manager.

The first thread try to close the entity manager factory which close all opened entity managers.

The second thread is triggered by an event and try to close the entity manager after a database access.

Both threads keep in the close method of the entity manager and never leave the close.

Why one of the threads cannot leave the close?

#2

Could you please send a thread dump that shows the deadlock?

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#3

We have only a profiling which can open with the VisualVM from JDK.

You can see this behavior in the attached profiling in the treads 'Java FX Application Thread' and 'ModalContext'.

 

 

#4

Unfortunately we need thread dumps in order to see a deadlock.

The profiling info does not include lock and deadlock information.

 

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#5

Unfortunately we have not a dump and the issue occurs only sometimes.

#6

Could you please take the a thread dump next time that this deadlock happens?

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#7

Yes, we try this next time.

#8

Hello,

we have a thread dump.

#9

Thank you for the thrad dump, it clearly shows a deadlock when:

  1. One thread is closing an EntityManager.
  2. Another thread is closing the EntityManagerFactory that owns that EntityManager.

Both threads require locks on both the EntityManager and the EntityManagerFactory but in a different order, so that can cause a deadlock.

Now that the issue is clear we hope to be able to fix it as soon as possible.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#10

Build 2.8.1_01 should solve the issue.

It is avilable now for download and soon also on Maven.

Thank you for this report.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login