openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hiroki Tateno (JIRA)" <>
Subject [jira] Created: (OPENJPA-913) A deadlock issue happens when DirtyListener is used
Date Mon, 09 Feb 2009 06:52:59 GMT
A deadlock issue happens when DirtyListener is used

                 Key: OPENJPA-913
             Project: OpenJPA
          Issue Type: Bug
          Components: kernel
    Affects Versions: 1.2.0
         Environment: Linux x86
            Reporter: Hiroki Tateno

A deadlock issue happens when OpenJPA entity manager is
concurrently called and DirtyListener is used and 
DirtyListener.beforeDirty calls an entity manager related 
operation. To call OpenJPA entity manager concurrently, 
we need to define openjpa.MulthThreaded option as true.

Following is test scenario.

1. Thread A calls entityMangaer.refresh() repeatedly.
   In refresh() method, entityManager acquires BrokerImpl
   lock. And then, entityManager acquires LifecycleEventManager
   lock to call lifecycle callback.
2. Thread B calls persistedObject.getAItems() (getting
   collection items).
3. In enhanced getItems() method, entityManager tries
   to mark it as "dirty". Before marking, callback listener
   DirtyListener.beforeDirty is called. In this point,
   LifecycleEventManager lock is acquired without acquiring
   BrokerImpl lock.
4. In the testcase, beforeDirty calls persistedObject.getAItems().
   And then, entity manager tries to acquire BrokerImpl lock.
   But, sometimes BrokerImpl lock is already acquired by Thread B.
   So, a deadlock issue happens. deadlock stack is as follows.

     [java] "Thread-1" prio=1 tid=0x09e98b28 nid=0x7fcc waiting on condition [0xb15f3000..0xb15f4130]
     [java]     at sun.misc.Unsafe.park(Native Method)
     [java]     at java.util.concurrent.locks.LockSupport.park(
     [java]     at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(
     [java]     at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(
     [java]     at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(
     [java]     at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(
     [java]     at java.util.concurrent.locks.ReentrantLock.lock(
     [java]     at org.apache.openjpa.kernel.BrokerImpl.lock(
     [java]     at org.apache.openjpa.kernel.BrokerImpl.beginOperation(
     [java]     at org.apache.openjpa.kernel.BrokerImpl.isActive(
     [java]     at org.apache.openjpa.kernel.StateManagerImpl.beforeRead(
     [java]     at org.apache.openjpa.kernel.StateManagerImpl.accessingField(
     [java]     at model.A.getAItems(
     [java]     at model.ADirtyListener.beforeDirty(
     [java]     at org.apache.openjpa.event.LifecycleEventManager.fireEvent(
     [java]     at org.apache.openjpa.event.LifecycleEventManager.fireEvent(
     [java]     - locked <0x51b4e4b0> (a org.apache.openjpa.event.LifecycleEventManager)
     [java]     at org.apache.openjpa.kernel.BrokerImpl.fireLifecycleEvent(
     [java]     at org.apache.openjpa.kernel.StateManagerImpl.fireLifecycleEvent(
     [java]     at org.apache.openjpa.kernel.StateManagerImpl.dirty(
     [java]     at org.apache.openjpa.kernel.StateManagerImpl.dirty(
     [java]     at org.apache.openjpa.util.Proxies.dirty(
     [java]     at org.apache.openjpa.util.ProxyCollections.beforeAdd(
     [java]     at$util$HashSet$proxy.add(Unknown Source)
     [java]     at business.Test$
     [java]     at

     [java] "Thread-0" prio=1 tid=0x09e9d010 nid=0x7fcb waiting for monitor entry [0xb1674000..0xb1674db0]
     [java]     at org.apache.openjpa.event.LifecycleEventManager.fireEvent(
     [java]     - waiting to lock <0x51b4e4b0> (a org.apache.openjpa.event.LifecycleEventManager)
     [java]     at org.apache.openjpa.kernel.BrokerImpl.fireLifecycleEvent(
     [java]     at org.apache.openjpa.kernel.StateManagerImpl.fireLifecycleEvent(
     [java]     at org.apache.openjpa.kernel.StateManagerImpl.clearFields(
     [java]     at org.apache.openjpa.kernel.StateManagerImpl.beforeRefresh(
     [java]     at org.apache.openjpa.kernel.BrokerImpl.refreshInternal(
     [java]     at org.apache.openjpa.kernel.BrokerImpl.refresh(
     [java]     at org.apache.openjpa.kernel.DelegatingBroker.refresh(
     [java]     at org.apache.openjpa.persistence.EntityManagerImpl.refresh(
     [java]     at business.Test$
     [java]     at

Intially the problem is reproduced on OpenJPA 1.x. But,
I verified the problem could be reproduced with latest 
OpenJPA head.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message