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

Bojan Janisch bojan.janisch at scai.fraunhofer.de
Wed Jul 17 04:18:33 EDT 2013


Hey again,

I've searched the net for similar problem and found this post: 

http://stackoverflow.com/questions/3429420/why-java-util-hashmap-getentry-can-block-my-program (17.07.13)

After that I've checked the CompositeClassLoader class and found that the object "classLoaderResultMap" (line 244) 
is indeed a normal HashMap and not thread safe. I'll modify it to a ConcurrentHashMap. I don't know if Drools was
built for a multi-threading environment, but if so, please change this in your next release.

Greetings

Bojan

----- Ursprüngliche Mail -----
Von: "Wolfgang Laun" <wolfgang.laun at gmail.com>
An: "Rules Users List" <rules-users at lists.jboss.org>
Gesendet: Dienstag, 16. Juli 2013 16:59:11
Betreff: Re: [rules-users] Getting infinite loops even with limitation of	fires

So you are saying that repeated runs with the same data livelock
somewhere in a rule's RHS but always in a different one? Do the thread
dumps have something in common, e.g., calls to some
org.drools.util.CompositeClassLoader method? (There was an issue with
class loading but I can't remember the details or version.)

-W

On 16/07/2013, Bojan Janisch <bojan.janisch at scai.fraunhofer.de> wrote:
> Hey Wolfgang,
>
> I thinks it's an infinite loop because the thread dump is always the same,
> doesn't matter when I look. The thread is running, not waiting or blocked
> which means that there has to be a spinlock that keeps the thread at the
> current position. And because this thing runs for almost 1 hour now I think
> it is an infinite loop.
>
> Do you have another idea why a thread should run for an endless time always
> at the same code segment if not because of an infinite loop?
>
> Greetings
>
> Bojan
>
> ----- Ursprüngliche Mail -----
> Von: "Wolfgang Laun" <wolfgang.laun at gmail.com>
> An: "Rules Users List" <rules-users at lists.jboss.org>
> Gesendet: Dienstag, 16. Juli 2013 11:55:48
> Betreff: Re: [rules-users] Getting infinite loops even with limitation
> of	fires
>
> 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
>>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
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