[rules-users] Getting infinite loops even with limitation of fires

Wolfgang Laun wolfgang.laun at gmail.com
Tue Jul 16 05:55:48 EDT 2013


Running longer than expected may not be due to overshooting the limit
for fired rules. Monitoring firings using a listener and registering
and counting where what actually happens is paramount.

How do you determine that there is in endless loop?

-W

On 16/07/2013, Bojan Janisch <bojan.janisch at scai.fraunhofer.de> wrote:
> Hello everyone,
>
> Recently I'm using Drools in a multithreaded environment. But after a while
> I see that Drools is running for endless time even though I gave him with
> fireAllRules(1000) a limitation to fire only 1000 rules. The occurrence is
> rule-independent, I've checked multiple times and each time it's another
> rule which works well if I run it separately.
>
> Could someone check the code of this stack trace? That's a thread dump of my
> last run.
>
> "ECJ Evaluation Thread 9" daemon prio=10 tid=0x00002b08a4fd9000 nid=0x2f90
> runnable [0x00002b08a9a82000]
>    java.lang.Thread.State: RUNNABLE
> 	at java.util.HashMap.getEntry(HashMap.java:347)
> 	at java.util.HashMap.containsKey(HashMap.java:335)
> 	at
> org.drools.util.CompositeClassLoader$CachingLoader.load(CompositeClassLoader.java:244)
> 	at
> org.drools.util.CompositeClassLoader$CachingLoader.load(CompositeClassLoader.java:237)
> 	at
> org.drools.util.CompositeClassLoader.loadClass(CompositeClassLoader.java:88)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> 	at
> defaultpkg.Rule_308_7dd58592a49c4dd1a6fd98dc64c74466DefaultConsequenceInvokerGenerated.evaluate(Unknown
> Source)
> 	at
> defaultpkg.Rule_308_7dd58592a49c4dd1a6fd98dc64c74466DefaultConsequenceInvoker.evaluate(Unknown
> Source)
> 	at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287)
> 	- locked <0x000000020865c080> (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 rulevolution.RulEvolution.runDrools(RulEvolution.java:348)
> 	at rulevolution.RulEvolution.evaluate(RulEvolution.java:183)
> 	at ec.simple.SimpleEvaluator.evalPopChunk(SimpleEvaluator.java:259)
> 	at
> ec.simple.SimpleEvaluator$SimpleEvaluatorThreadCG.run(SimpleEvaluator.java:341)
> 	at ec.util.ThreadPool$PoolThread.run(ThreadPool.java:57)
>
>    Locked ownable synchronizers:
> 	- None
>
> Also here the rule and code snipped I'm using to prove that the infinite
> loop does not come from my code:
>
> //kSession is a StatefulKnowledgeSession
> try {
> 	//Limiting the Activation will prevent infinite loops
> 	kSession.fireAllRules(1000);
> } catch (Exception e) {
> 	System.out.println("error while processing :: " + e.toString());
> 	System.out.println(rule);
> } finally {
> 	kSession.dispose();
> }
> -------------------------------------------------------------------
> rule "308"
> no-loop
> when
>
> $0:NormalizedNamedEntity(
> ct_0:CoveredText,
> cp_0:Concept,
> label_0:getConcept().getPrefLabel().value,
> getConcept().identifierSource.toLowerCase.contains("ops"))
>
> $1:NormalizedNamedEntity(
> ct_1:CoveredText,
> cp_1:Concept,
> label_1:getConcept().getPrefLabel().value,
> getConcept().identifierSource.toLowerCase.contains("bodyside"))
>
> then
> int start = getStart($0,$1);
> int ende = getStop($0,$1);
> String attribute = label_0+" "+label_1;
> insert(annotate(aJCas, "Operation", 309, attribute, start, ende, "",
> attribute));
> end
>
> I appreciate any help to solve this occurrence.
>
> Greetings
>
> Bojan
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list