Has anyone run into this issue? I’ve found a couple other references to deadlocks but nothing that seems to match exactly what I’m seeing. I’m running with drools 5.1.1 and using the BatchExecutionCommand interface to feed a set of commands into my StatefulKnowledgeSession. I also have a simple rule that uses the duration attribute to clean up old facts. The problem is that the thread that executes the rule associated with the duration attribute acquires the lock associated with the DefaultAgenda class object and subsequently tries to acquire the locks managed by the AbstractWorkingMemory. However, my main thread that uses the BatchExecutionCommand interface could run while the other thread is running and this thread first acquires the AbstractWorkingMemory locks and later tries to acquire the DefaultAgenda class object lock resulting in the deadlock.
Here’s is the stack trace for the thread that runs when duration expires:
Unsafe.park(boolean, long) line: not available [native method]
LockSupport.park(Object) line: 158
ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).parkAndCheckInterrupt() line: 747
ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquireQueued(AbstractQueuedSynchronizer$Node, int) line: 778
ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquire(int) line: 1114
ReentrantLock$NonfairSync.lock() line: 186
ReentrantLock.lock() line: 262
ReteooStatefulSession(AbstractWorkingMemory).retract(FactHandle, boolean, boolean, Rule, Activation) line: 1256
DefaultKnowledgeHelper.retract(FactHandle) line: 201
DefaultKnowledgeHelper.retract(Object) line: 214
Rule_Automatically_Remove_Old_Events_0.defaultConsequence(KnowledgeHelper, Event, FactHandle) line: 10
Rule_Automatically_Remove_Old_Events_0DefaultConsequenceInvoker.evaluate(KnowledgeHelper, WorkingMemory) line: 29
DefaultAgenda.fireActivation(Activation) line: 917
Scheduler$ActivationTimerJob.execute(JobContext) line: 73
JDKTimerService$JDKCallableJob.call() line: 147
JDKTimerService$JDKCallableJob.call() line: 125
FutureTask$Sync.innerRun() line: 303
ScheduledThreadPoolExecutor$ScheduledFutureTask<V>(FutureTask<V>).run() line: 138
ScheduledThreadPoolExecutor$ScheduledFutureTask<V>.access$301(ScheduledThreadPoolExecutor$ScheduledFutureTask) line: 98
ScheduledThreadPoolExecutor$ScheduledFutureTask<V>.run() line: 207
ThreadPoolExecutor$Worker.runTask(Runnable) line: 886
ThreadPoolExecutor$Worker.run() line: 908
Thread.run() line: 619
And here’s the stack trace of the thread using the BatchExecutionCommand interface:
DefaultAgenda.fireActivation(Activation) line: 889
DefaultAgenda.fireNextItem(AgendaFilter) line: 856
DefaultAgenda.fireAllRules(AgendaFilter, int) line: 1071
ReteooStatefulSession(AbstractWorkingMemory).fireAllRules(AgendaFilter, int) line: 785
ReteooStatefulSession(AbstractWorkingMemory).fireAllRules() line: 751
StatefulKnowledgeSessionImpl.fireAllRules() line: 218
FireAllRulesCommand.execute(Context) line: 99
FireAllRulesCommand.execute(Context) line: 33
BatchExecutionCommandImpl.execute(Context) line: 159
BatchExecutionCommandImpl.execute(Context) line: 81
StatefulKnowledgeSessionImpl.execute(Context, Command<T>) line: 887
StatefulKnowledgeSessionImpl.execute(Command<T>) line: 862
Rules$RuleRunnerThread.run() line: 554
The rule with the duration attribute is very simple and included below:
rule "Automatically Remove Old Events"
agenda-group "SYSTEM"
// 1 hour (specified in milliseconds)
duration 3600000
when
$event : Event(eventId : id)
not SituationEvent(correlator == eventId)
then
retract($event);
end
CONFIDENTIALITY NOTICE: The information contained in this e-mail and its attachments are privileged and confidential and may contain proprietary, copyrighted or other legally protected information which is intended solely for the use of the addressee(s). If you are not the intended recipient, you are hereby notified that any disclosure, use, copying or distribution of this communication is strictly prohibited. Please notify the sender immediately and permanently delete this e-mail from your computer.