this is mow fixed in master. Thanks for finding the bug. Please don't
forget to make lira's in the future.
@mario: Can you paste the jira link you created for this commit in the end.
Mark
On Tue, Feb 25, 2014 at 5:24 AM, Mark Proctor <mproctor(a)codehaus.org> wrote:
I have managed to reduce down the project from mxv into a single unit
test
that can be added to Misc2Test. I turned tracing on, and it fails while
evaluating R1:
2014-02-25 05:00:16,192 [main] TRACE Rule[name=R1] segments=2
TupleSets[insertSize=0, deleteSize=0, updateSize=0]
2014-02-25 05:00:16,192 [main] TRACE 11 [JoinNode(5) -
[ClassObjectType
class=org.drools.compiler.integrationtests.Misc2Test$Foo2]]
TupleSets[insertSize=0, deleteSize=0, updateSize=0]
2014-02-25 05:00:16,192 [main] TRACE Skip Segment 0
2014-02-25 05:00:16,192 [main] TRACE Segment 1
2014-02-25 05:00:16,192 [main] TRACE 11 [JoinNode(7) -
[ClassObjectType class=org.drools.compiler.Person]] TupleSets[insertSize=0,
deleteSize=0, updateSize=1]
2014-02-25 05:00:16,193 [main] TRACE rightTuples
TupleSets[insertSize=1, deleteSize=0, updateSize=0]
I've provided the new test and the full trace log below.
The problem is the node sharing of Foo2. R1 thinks it's propagating an
update, when it never passed R1's Foo2 before, so it should propagate as an
update for R2 but an insert for R1. I suspect the problem is related to the
SegmentPropagator when it is updated after moving from the first shared
segment, to the two child segments.
Please try to avoid submitting project jars. It takes a lot more time for
us to setup and work with, which will delay our time in getting back to
you. Ideally create a reduced single test method, as per blow, that is self
contained, and submit it with pull request and associated JIRA. see:
http://docs.jboss.org/drools/release/5.6.0.Final/droolsjbpm-introduction-...
@Test*public void *testSharedNotWithLeftUpdateAndRightInsert() *throws *Exception {
String str = *"import " *+ Foo.*class*.getCanonicalName() +
*";**\n**" *+ *"import " *+ Foo2.*class*.getCanonicalName()
+ *";**\n**" *+ *"import " *+
Person.*class*.getCanonicalName() + *";**\n**" *+ *"rule R1
when**\n**" *+ *" f1 : Foo( )**\n**" *+ *"
Foo2( )**\n**" *+ *" Person( age == f1.x )**\n**" *+
*"then**\n**" *+ *"end**\n**" *+ *"rule
R2 when**\n**" *+ *" Foo( )**\n**" *+ *"
f2 : Foo2( )**\n**" *+ *" not Person()**\n**" *+
*"then**\n**" *+ *" modify( f2 ) { x = 3};**\n**" *+
*" insert( new Person() );**\n**" *+
*"end**\n**"*; KnowledgeBase kbase = loadKnowledgeBaseFromString(str);
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); Foo f1 = *new
*Foo(); Foo2 f2 = *new *Foo2(); ksession.insert( f1 ); ksession.insert( f2 );
*assertEquals*(2, ksession.fireAllRules() ); *assertEquals*( 3, f2.getX() );}
For those interested, here is the full trace output once trace is turned
on:
2014-02-25 05:13:33,610 [main] DEBUG Starting Engine in PHREAK mode
2014-02-25 05:13:33,715 [main] TRACE Adding Rule R1
2014-02-25 05:13:33,720 [main] TRACE Adding Rule R2
2014-02-25 05:13:33,809 [main] TRACE Insert [fact
0:1:1668059028:1668059028:1:DEFAULT:NON_TRAIT:org.drools.compiler.integrationtests.Misc2Test$Foo@636c8f94
]
2014-02-25 05:13:33,822 [main] TRACE LinkNode notify=false nmask=1 smask=1
spos=0 rules=
2014-02-25 05:13:33,823 [main] TRACE LinkSegment smask=2 rmask=2 name=R2
2014-02-25 05:13:33,831 [main] TRACE LinkNode notify=true nmask=1 smask=1
spos=0 rules=[RuleMem R1], [RuleMem R2]
2014-02-25 05:13:33,832 [main] TRACE Insert [fact
0:2:588638666:588638666:2:DEFAULT:NON_TRAIT:org.drools.compiler.integrationtests.Misc2Test$Foo2@2315e9ca
]
2014-02-25 05:13:33,833 [main] TRACE BetaNode insert=1
stagedInsertWasEmpty=true
2014-02-25 05:13:33,833 [main] TRACE LinkNode notify=true nmask=2 smask=3
spos=0 rules=[RuleMem R1], [RuleMem R2]
2014-02-25 05:13:33,833 [main] TRACE LinkSegment smask=1 rmask=1 name=R1
2014-02-25 05:13:33,834 [main] TRACE LinkSegment smask=1 rmask=3 name=R2
2014-02-25 05:13:33,834 [main] TRACE LinkRule name=R2
2014-02-25 05:13:33,855 [main] TRACE Queue RuleAgendaItem [Activation
rule=R2, act#=0, salience=0, tuple=null]
2014-02-25 05:13:33,856 [main] TRACE Queue Added 1 [Activation rule=R2,
act#=0, salience=0, tuple=null]
2014-02-25 05:13:33,856 [main] TRACE Rule[name=R2] segments=2
TupleSets[insertSize=1, deleteSize=0, updateSize=0]
2014-02-25 05:13:33,856 [main] TRACE 1 [JoinNode(5) -
[ClassObjectType
class=org.drools.compiler.integrationtests.Misc2Test$Foo2]]
TupleSets[insertSize=1, deleteSize=0, updateSize=0]
2014-02-25 05:13:33,857 [main] TRACE Segment 0
2014-02-25 05:13:33,857 [main] TRACE 1 [JoinNode(5) -
[ClassObjectType
class=org.drools.compiler.integrationtests.Misc2Test$Foo2]]
TupleSets[insertSize=1, deleteSize=0, updateSize=0]
2014-02-25 05:13:33,865 [main] TRACE rightTuples
TupleSets[insertSize=1, deleteSize=0, updateSize=0]
2014-02-25 05:13:33,867 [main] TRACE Segment 1
2014-02-25 05:13:33,867 [main] TRACE 2 [NotNode(9) -
[ClassObjectType class=org.drools.compiler.Person]] TupleSets[insertSize=1,
deleteSize=0, updateSize=0]
2014-02-25 05:13:33,867 [main] TRACE Segment 1
2014-02-25 05:13:33,868 [main] TRACE 2 [NotNode(9) -
[ClassObjectType class=org.drools.compiler.Person]] TupleSets[insertSize=1,
deleteSize=0, updateSize=0]
2014-02-25 05:13:33,868 [main] TRACE rightTuples
TupleSets[insertSize=0, deleteSize=0, updateSize=0]
2014-02-25 05:13:33,870 [main] TRACE 3 [RuleTerminalNode(10):
rule=R2] TupleSets[insertSize=1, deleteSize=0, updateSize=0]
2014-02-25 05:13:33,871 [main] TRACE Segment 1
2014-02-25 05:13:33,871 [main] TRACE 3 [RuleTerminalNode(10):
rule=R2] TupleSets[insertSize=1, deleteSize=0, updateSize=0]
2014-02-25 05:13:33,871 [main] TRACE Fire "R2"
[[ R2 active=false ] [ null
[fact
0:2:588638666:588638666:2:DEFAULT:NON_TRAIT:org.drools.compiler.integrationtests.Misc2Test$Foo2@2315e9ca
]
[fact
0:1:1668059028:1668059028:1:DEFAULT:NON_TRAIT:org.drools.compiler.integrationtests.Misc2Test$Foo@636c8f94]
] ]
2014-02-25 05:13:33,877 [main] TRACE Update [fact
0:2:588638666:588638666:3:DEFAULT:NON_TRAIT:org.drools.compiler.integrationtests.Misc2Test$Foo2@2315e9ca
]
2014-02-25 05:13:33,879 [main] TRACE LinkSegment smask=1 rmask=1 name=R1
2014-02-25 05:13:33,879 [main] TRACE LinkSegment smask=1 rmask=3 name=R2
2014-02-25 05:13:33,879 [main] TRACE LinkRule name=R2
2014-02-25 05:13:33,880 [main] TRACE Insert [fact
0:3:1618732380:-62068830:4:DEFAULT:LEGACY_TRAITABLE:[Person name='null
age='0' likes='null']]
2014-02-25 05:13:33,880 [main] TRACE BetaNode insert=1
stagedInsertWasEmpty=true
2014-02-25 05:13:33,880 [main] TRACE LinkNode notify=true nmask=1 smask=1
spos=1 rules=[RuleMem R1]
2014-02-25 05:13:33,880 [main] TRACE LinkSegment smask=2 rmask=3 name=R1
2014-02-25 05:13:33,881 [main] TRACE LinkRule name=R1
2014-02-25 05:13:33,881 [main] TRACE Queue RuleAgendaItem [Activation
rule=R1, act#=2, salience=0, tuple=null]
2014-02-25 05:13:33,881 [main] TRACE Queue Added 1 [Activation rule=R1,
act#=2, salience=0, tuple=null]
2014-02-25 05:13:33,881 [main] TRACE LinkNode notify=true nmask=1 smask=1
spos=1 rules=[RuleMem R2]
2014-02-25 05:13:33,882 [main] TRACE LinkSegment smask=2 rmask=3 name=R2
2014-02-25 05:13:33,882 [main] TRACE LinkRule name=R2
2014-02-25 05:13:33,882 [main] TRACE Rule[name=R1] segments=2
TupleSets[insertSize=0, deleteSize=0, updateSize=0]
2014-02-25 05:13:33,882 [main] TRACE 4 [JoinNode(5) -
[ClassObjectType
class=org.drools.compiler.integrationtests.Misc2Test$Foo2]]
TupleSets[insertSize=0, deleteSize=0, updateSize=0]
2014-02-25 05:13:33,883 [main] TRACE Segment 0
2014-02-25 05:13:33,883 [main] TRACE 4 [JoinNode(5) -
[ClassObjectType
class=org.drools.compiler.integrationtests.Misc2Test$Foo2]]
TupleSets[insertSize=0, deleteSize=0, updateSize=0]
2014-02-25 05:13:33,884 [main] TRACE rightTuples
TupleSets[insertSize=0, deleteSize=0, updateSize=1]
2014-02-25 05:13:33,884 [main] TRACE Segment 1
2014-02-25 05:13:33,884 [main] TRACE 5 [JoinNode(7) -
[ClassObjectType class=org.drools.compiler.Person]] TupleSets[insertSize=0,
deleteSize=0, updateSize=1]
2014-02-25 05:13:33,884 [main] TRACE Segment 1
2014-02-25 05:13:33,885 [main] TRACE 5 [JoinNode(7) -
[ClassObjectType class=org.drools.compiler.Person]] TupleSets[insertSize=0,
deleteSize=0, updateSize=1]
2014-02-25 05:13:33,885 [main] TRACE rightTuples
TupleSets[insertSize=1, deleteSize=0, updateSize=0]
java.lang.NullPointerException
at
org.drools.core.util.index.LeftTupleIndexHashTable.remove(LeftTupleIndexHashTable.java:386)
at
org.drools.core.phreak.RuleNetworkEvaluator.doUpdatesReorderLeftMemory(RuleNetworkEvaluator.java:799)