-
Bug
-
Resolution: Done
-
Major
-
jBPM 6.3.0.CR2
-
None
-
NEW
-
NEW
Under the conditions:
- Singleton
- outer JTA transaction
- current TransactionLockInterceptor (https://github.com/droolsjbpm/drools/commit/249f763d9a9eaa87d84e94536684624a81c2c81e)
- Access ksession multiple times inside the transaction
- Multi-thread accesses
you will hit a deadlock like this.
Found one Java-level deadlock: ============================= "pool-4-thread-2": waiting for ownable synchronizer 0x00000007b0bb32c8, (a java.util.concurrent.locks.ReentrantLock$NonfairSync), which is held by "pool-4-thread-1" "pool-4-thread-1": waiting to lock monitor 0x00007f9598b1e9f8 (object 0x00000007af6ffad0, a org.drools.persistence.SingleSessionCommandService), which is held by "pool-4-thread-2" Java stack information for the threads listed above: =================================================== "pool-4-thread-2": at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000007b0bb32c8> (a java.util.concurrent.locks.ReentrantLock$NonfairSync) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186) at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197) at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:214) at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:290) at org.drools.persistence.jta.TransactionLockInterceptor.execute(TransactionLockInterceptor.java:81) at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:377) - locked <0x00000007af6ffad0> (a org.drools.persistence.SingleSessionCommandService) at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.getProcessInstance(CommandBasedStatefulKnowledgeSession.java:120) at com.sample.ProcessJPATest$1.run(ProcessJPATest.java:124) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) "pool-4-thread-1": at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:377) - waiting to lock <0x00000007af6ffad0> (a org.drools.persistence.SingleSessionCommandService) at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.getProcessInstance(CommandBasedStatefulKnowledgeSession.java:120) at com.sample.ProcessJPATest$1.run(ProcessJPATest.java:130) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Found 1 deadlock.
Attached a reproducer TransactionLockInterceptor.zip (mvn clean test).