ObjectDB ObjectDB

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?

edit
delete
#2

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

ObjectDB Support
edit
delete
#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'.

 

 

edit
delete
#4

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

The profiling info does not include lock and deadlock information.

 

ObjectDB Support
edit
delete
#5

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

edit
delete
#6

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

ObjectDB Support
edit
delete
#7

Yes, we try this next time.

edit
delete
#8

Hello,

we have a thread dump.

edit
delete
#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
edit
delete
#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
edit
delete

Reply

To post on this website please sign in.