Bug 995078 - Deadlock between AbstractWorkingMemory and DefaultAgenda
Deadlock between AbstractWorkingMemory and DefaultAgenda
Status: VERIFIED
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion) (Show other bugs)
BRMS 5.3.1
Unspecified Unspecified
unspecified Severity unspecified
: GA
: ---
Assigned To: Mario Fusco
Marek Winkler
:
Depends On:
Blocks: 986451
  Show dependency treegraph
 
Reported: 2013-08-08 09:55 EDT by Mario Fusco
Modified: 2013-09-12 04:41 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker DROOLS-206 Major Resolved Deadlock between AbstractWorkingMemory and DefaultAgenda 2014-05-02 05:32:06 EDT

  None (edit)
Description Mario Fusco 2013-08-08 09:55:40 EDT
I experienced a deadlock when running in STREAM mode and using negative patterns with temporal constraints.
When the rule gets fired by the installed timer job and at the same time another thread is firing rules, a deadlock can occur:

1. [rule firing thread] StatefulKnowledgeSessionImpl.execute(StatefulKnowledgeSessionImpl.java:820)
acquires lock in AbstractWorkingMemory

2. [timer-thread] DefaultAgenda.fireActivation()
call of synchronized method

3. [rule firing thread] DefaultAgenda.fireActivation()
synchronized method, wait for other thread to exit synchornized method

4. [timer-thread] AbstractWorkingMemory.getGlobal()
tries to access a global, tries to acquire lock in AbstractWorkingMemory which is held by the other thread

--> Deadlock

Excerpt from thread dump:

"http-thread-pool-8082(374)":
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1264)

    waiting to lock <0x00007f50407e4950> (a org.drools.common.DefaultAgenda)
    at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221)
    at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456)
    at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710)
    at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:679)
    at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:234)
    at org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:102)
    at org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:32)
    at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:155)
    at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:76)
    at org.drools.impl.StatefulKnowledgeSessionImpl.execute(StatefulKnowledgeSessionImpl.java:821)

"pool-4251-thread-1":
at sun.misc.Unsafe.park(Native Method)

    parking to wait for 0x00007f503fc71a20> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:778)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1114)
    at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:186)
    at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:262)
    at org.drools.common.AbstractWorkingMemory.getGlobal(AbstractWorkingMemory.java:634)
    at myrules.Rule_ruleWithTimeout_ece4a3c9fc2741a4ab97a92b77611203DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
    at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
    locked <0x00007f50407e4950> (a org.drools.common.DefaultAgenda)
    at org.drools.common.DefaultAgenda.fireTimedActivation(DefaultAgenda.java:1344)
    locked <0x00007f50407e4950> (a org.drools.common.DefaultAgenda)
    at org.drools.common.Scheduler$ActivationTimerJob.execute(Scheduler.java:83)
Comment 2 Marek Winkler 2013-09-12 04:41:41 EDT
Verified on 5.3.1.BRMS-P04.

Note You need to log in before you can comment on or make changes to this bug.