Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-776

Deadlock trying to synchronize 'eager' field in DefaultAgenda (between drools-worker thread and other)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 6.3.0.Beta1
    • 6.2.0.Final
    • None
    • None

      Migrating from drools 6.0.1.Final to 6.2.0.Final there seems to be a rare deadlock trying to synchronize the DefaultAgenda eager field, i have seen it only 2 or three times now as it seems very dificult to reproduce.

      In our scenario the test is calling kSession.fireUntilHalt() in a new thread, then in the main thread waiting for some events to happens (by calling in a loop: kSession.getObjects(new ClassObjectFilter(_clazz)))) and then doing some other assert checks.

      See the stacktrace i took with jstack:

      Java stack information for the threads listed above:
      ===================================================
      "Thread-5":
      	at org.drools.core.phreak.RuleExecutor.evaluateNetwork(RuleExecutor.java:92)
      	- waiting to lock <0x00000000ff245780> (a org.drools.core.phreak.RuleExecutor)
      	at org.drools.core.common.DefaultAgenda.evaluateEagerList(DefaultAgenda.java:1044)
      	- locked <0x00000000ff3dab38> (a org.drools.core.util.LinkedList)
      	at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:996)
      	at org.drools.core.common.DefaultAgenda.fireUntilHalt(DefaultAgenda.java:1258)
      	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireUntilHalt(StatefulKnowledgeSessionImpl.java:1333)
      	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireUntilHalt(StatefulKnowledgeSessionImpl.java:1310)
      	at bar.foo.AIDelayTest$1.run(AIDelayTest.java:101)
      	at java.lang.Thread.run(Thread.java:745)
      "drools-worker-2":
      	at org.drools.core.common.DefaultAgenda.addEagerRuleAgendaItem(DefaultAgenda.java:287)
      	- waiting to lock <0x00000000ff3dab38> (a org.drools.core.util.LinkedList)
      	at org.drools.core.reteoo.PathMemory.queueRuleAgendaItem(PathMemory.java:159)
      	at org.drools.core.reteoo.PathMemory.doUnlinkRule(PathMemory.java:133)
      	- locked <0x00000000ff2457a0> (a org.drools.core.reteoo.PathMemory)
      	at org.drools.core.reteoo.PathMemory.unlinkedSegment(PathMemory.java:173)
      	at org.drools.core.reteoo.SegmentMemory.unlinkNode(SegmentMemory.java:203)
      	at org.drools.core.reteoo.BetaMemory.unlinkNode(BetaMemory.java:100)
      	at org.drools.core.reteoo.BetaNode.doDeleteRightTuple(BetaNode.java:377)
      	at org.drools.core.reteoo.JoinNode.retractRightTuple(JoinNode.java:107)
      	at org.drools.core.reteoo.ObjectTypeNode.doRetractObject(ObjectTypeNode.java:345)
      	at org.drools.core.reteoo.ObjectTypeNode.retractObject(ObjectTypeNode.java:337)
      	at org.drools.core.reteoo.EntryPointNode.retractObject(EntryPointNode.java:381)
      	at org.drools.core.common.NamedEntryPoint.delete(NamedEntryPoint.java:615)
      	at org.drools.core.base.DefaultKnowledgeHelper.delete(DefaultKnowledgeHelper.java:495)
      	at org.drools.core.base.DefaultKnowledgeHelper.retract(DefaultKnowledgeHelper.java:486)
      	at bar.foo.Rule_basic$u46$delayExecution$u46$01246876731.defaultConsequence(Rule_basic$u46$delayExecution$u46$01246876731.java:7)
      	at bar.foo.Rule_basic$u46$delayExecution$u46$01246876731DefaultConsequenceInvokerGenerated.evaluate(Unknown Source)
      	at bar.foo.Rule_basic$u46$delayExecution$u46$01246876731DefaultConsequenceInvoker.evaluate(Unknown Source)
      	at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1114)
      	- locked <0x00000000ff3da978> (a org.drools.core.common.DefaultAgenda)
      	at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:160)
      	at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:112)
      	- locked <0x00000000ff245780> (a org.drools.core.phreak.RuleExecutor)
      	at org.drools.core.phreak.PhreakTimerNode$Executor.qevauateAndFireRule(PhreakTimerNode.java:485)
      	at org.drools.core.phreak.PhreakTimerNode$TimerNodeJob$1.run(PhreakTimerNode.java:420)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      
      Found 1 deadlock.
      
      

              mfusco@redhat.com Mario Fusco
              jcgarciam_jira Juan Carlos Garcia (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: