Bug 995078 - Deadlock between AbstractWorkingMemory and DefaultAgenda
Summary: Deadlock between AbstractWorkingMemory and DefaultAgenda
Keywords:
Status: VERIFIED
Alias: None
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion)
Version: BRMS 5.3.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: GA
: ---
Assignee: Mario Fusco
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 986451
TreeView+ depends on / blocked
 
Reported: 2013-08-08 13:55 UTC by Mario Fusco
Modified: 2024-01-01 01:36 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker DROOLS-206 0 Major Resolved Deadlock between AbstractWorkingMemory and DefaultAgenda 2014-05-02 09:32:06 UTC

Description Mario Fusco 2013-08-08 13:55:40 UTC
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 08:41:41 UTC
Verified on 5.3.1.BRMS-P04.


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