Bug 986465

Summary: Rule Engine Crashes when used Slide Window constraints and kAgent is configured as incremental processing
Product: [JBoss] JBoss Enterprise BRMS Platform 5 Reporter: Alessandro Lazarotti <alazarot>
Component: BRE (Expert, Fusion)Assignee: Mario Fusco <mfusco>
Status: VERIFIED --- QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: BRMS 5.3.1CC: mfusco, nwallace
Target Milestone: GA   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1031099 (view as bug list) Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1031099, 986451    
Attachments:
Description Flags
Unit test
none
Maven project with Alessandro's reproducer none

Description Alessandro Lazarotti 2013-07-19 20:55:11 UTC
Description of problem:

When there is a Slide Window constraint and the kbase is configured to receive incremental changes from the kagent (drools.agent.newInstance as false) - the engine crashes


How reproducible:
Running the unit test attached.

Actual results:
After some cycles the test hangs just after a changeset update and a next fact insert. 

Expected results:
No crash

Comment 1 Alessandro Lazarotti 2013-07-19 20:58:52 UTC
Created attachment 775963 [details]
Unit test

Comment 2 JBoss JIRA Server 2013-07-19 22:15:17 UTC
Davide Sottara <dsotty> made a comment on jira DROOLS-195

no crashes detected using 5.6.0-SNAPSHOT

Comment 3 Edson Tirelli 2013-07-23 14:06:30 UTC
Lukas, Alessandro, what is the context for this ticket? Is it for 5.3.x or 6.x? If it is for 5, was it reported by a customer and we need to backport the fixes?

Just trying to understand what needs to be done here.

Comment 5 Edson Tirelli 2013-07-23 14:20:14 UTC
Just got the e-mail from Alessandro:

=============
They should be part of the Roll Up Patch BRMS_5.3.1_3_2013 - 
https://bugzilla.redhat.com/show_bug.cgi?id=986451
BZs to it should be added and committed until 09/Aug (3 weeks) - after 
that is started the productisation work. So an ETA to get it fixed is 
until 09-Aug.
=============

Comment 6 Mario Fusco 2013-08-08 08:38:59 UTC
I ran the provided unit test on the 5.3.x branch twice doing 1000+ cycles for each run but I couldn't reproduce this issue, so I am assuming the fix has been already backported.

Comment 7 Marek Winkler 2013-09-13 16:02:54 UTC
I am able to reproduce that the engine gets stuck during the test on 5.3.1.BRMS-P04. Although I can see no exception (neither in any log, nor in the output), the main test thread execution hangs (the console keeps printing messages about updating the drl file in another thread).

To reproduce, please run the reproducer in the attached maven project ('mvn clean test').

It seems one of the engine threads gets stuck in the following stacktrace:

Name: Thread-0
State: RUNNABLE
Total blocked: 0  Total waited: 2

Stack trace: 
org.drools.reteoo.BetaNode.doRemove(BetaNode.java:381)
org.drools.common.BaseNode.remove(BaseNode.java:105)
org.drools.reteoo.RuleTerminalNode.doRemove(RuleTerminalNode.java:367)
org.drools.common.BaseNode.remove(BaseNode.java:105)
org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:242)
   - locked org.drools.reteoo.ReteooBuilder@622e199e
org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:468)
org.drools.common.AbstractRuleBase.removeRule(AbstractRuleBase.java:971)
org.drools.common.AbstractRuleBase.mergePackage(AbstractRuleBase.java:739)
org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:557)
org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:481)
org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:150)
org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:1083)
org.drools.agent.impl.KnowledgeAgentImpl.incrementalBuildResources(KnowledgeAgentImpl.java:969)
   - locked org.drools.agent.impl.KnowledgeAgentImpl$RegisteredResourceMap@4094066d
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:673)
   - locked org.drools.agent.impl.KnowledgeAgentImpl$RegisteredResourceMap@4094066d
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:201)
   - locked org.drools.agent.impl.KnowledgeAgentImpl$RegisteredResourceMap@4094066d
org.drools.agent.impl.KnowledgeAgentImpl$ChangeSetNotificationDetector.run(KnowledgeAgentImpl.java:1268)
java.lang.Thread.run(Thread.java:722)

Comment 8 Marek Winkler 2013-09-13 16:07:45 UTC
Created attachment 797426 [details]
Maven project with Alessandro's reproducer

Comment 9 Alessandro Lazarotti 2013-09-18 17:58:27 UTC
Neil, why this issue was moved from ASSIGNED to ON_QA ? I think that Mario is still working over it to get a fix

Comment 10 Mario Fusco 2013-09-18 18:46:30 UTC
Fixed by https://github.com/droolsjbpm/drools/commit/8f3783dd1

Comment 11 JBoss JIRA Server 2013-09-19 07:01:50 UTC
Mario Fusco <mario.fusco> updated the status of jira DROOLS-195 to Resolved

Comment 12 Marek Winkler 2013-09-20 08:51:29 UTC
Verified on 5.3.1.BRMS-P04.