<div dir="ltr">this is mow fixed in master. Thanks for finding the bug. Please don&#39;t forget to make lira&#39;s in the future.<div><br></div><div>@mario: Can you paste the jira link you created for this commit in the end.<br>
<div><br></div><div>Mark</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 25, 2014 at 5:24 AM, Mark Proctor <span dir="ltr">&lt;<a href="mailto:mproctor@codehaus.org" target="_blank">mproctor@codehaus.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>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:</div>
<div><div>2014-02-25 05:00:16,192 [main] TRACE Rule[name=R1] segments=2 TupleSets[insertSize=0, deleteSize=0, updateSize=0]</div><div>2014-02-25 05:00:16,192 [main] TRACE &nbsp; &nbsp; &nbsp;11 [JoinNode(5) - [ClassObjectType class=org.drools.compiler.integrationtests.Misc2Test$Foo2]] TupleSets[insertSize=0, deleteSize=0, updateSize=0]</div>
<div>2014-02-25 05:00:16,192 [main] TRACE &nbsp; &nbsp; &nbsp;Skip Segment 0</div><div>2014-02-25 05:00:16,192 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp;Segment 1</div><div>2014-02-25 05:00:16,192 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp;11 [JoinNode(7) - [ClassObjectType class=org.drools.compiler.Person]] TupleSets[insertSize=0, deleteSize=0, updateSize=1]</div>
<div>2014-02-25 05:00:16,193 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp;rightTuples TupleSets[insertSize=1, deleteSize=0, updateSize=0]</div></div><div>I&rsquo;ve provided the new test and the full trace log below.</div><div><br></div><div>The problem is the node sharing of Foo2. R1 thinks it&rsquo;s propagating an update, when it never passed R1&rsquo;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.</div>
<div><br></div><div>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:</div>
<div><a href="http://docs.jboss.org/drools/release/5.6.0.Final/droolsjbpm-introduction-docs/html/gettingstarted.html" target="_blank">http://docs.jboss.org/drools/release/5.6.0.Final/droolsjbpm-introduction-docs/html/gettingstarted.html</a></div>
<div><br></div><div><br></div><div><div style="border:1px inset;padding:2%"><pre style="margin-bottom:0px;font-family:Menlo;margin-top:0px;padding:6px" bgcolor="#ffffff"><font color="#808000">@Test
</font><font color="#000080"><b>public void </b></font><font color="#000000">testSharedNotWithLeftUpdateAndRightInsert() </font><font color="#000080"><b>throws </b></font><font color="#000000">Exception {
</font><font color="#000000">    String str =
</font><font color="#000000">            </font><font color="#008000"><b>&quot;import &quot; </b></font><font color="#000000">+ Foo.</font><font color="#000080"><b>class</b></font><font color="#000000">.getCanonicalName() + </font><font color="#008000"><b>&quot;;</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;import &quot; </b></font><font color="#000000">+ Foo2.</font><font color="#000080"><b>class</b></font><font color="#000000">.getCanonicalName() + </font><font color="#008000"><b>&quot;;</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;import &quot; </b></font><font color="#000000">+ Person.</font><font color="#000080"><b>class</b></font><font color="#000000">.getCanonicalName() + </font><font color="#008000"><b>&quot;;</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;rule R1 when</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;    f1 : Foo( )</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;    Foo2( )</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;    Person( age == f1.x )</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;then</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;end</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;rule R2 when</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;    Foo(  )</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;    f2 : Foo2( )</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;    not Person()</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;then</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;    modify( f2 ) { x = 3};</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;    insert( new Person() );</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot; </b></font><font color="#000000">+
</font><font color="#000000">            </font><font color="#008000"><b>&quot;end</b></font><font color="#000080"><b>\n</b></font><font color="#008000"><b>&quot;</b></font><font color="#000000">;
</font><font color="#000000">
</font><font color="#000000">    KnowledgeBase kbase = loadKnowledgeBaseFromString(str);
</font><font color="#000000">    StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
</font><font color="#000000">    Foo f1 = </font><font color="#000080"><b>new </b></font><font color="#000000">Foo();
</font><font color="#000000">    Foo2 f2 = </font><font color="#000080"><b>new </b></font><font color="#000000">Foo2();
</font><font color="#000000">    ksession.insert( f1 );
</font><font color="#000000">    ksession.insert( f2 );
</font><font color="#000000">    </font><font color="#000000"><i>assertEquals</i></font><font color="#000000">(</font><font color="#0000ff">2</font><font color="#000000">, ksession.fireAllRules() );
</font><font color="#000000">    </font><font color="#000000"><i>assertEquals</i></font><font color="#000000">( </font><font color="#0000ff">3</font><font color="#000000">, f2.getX() );
</font><font color="#000000">}</font></pre></div><div><br></div></div><div>For those interested, here is the full trace output once trace is turned on:</div><div><br></div><div><div><div>2014-02-25 05:13:33,610 [main] DEBUG Starting Engine in PHREAK mode</div>
<div>2014-02-25 05:13:33,715 [main] TRACE Adding Rule R1</div><div>2014-02-25 05:13:33,720 [main] TRACE Adding Rule R2</div><div>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]</div>
<div>2014-02-25 05:13:33,822 [main] TRACE LinkNode notify=false nmask=1 smask=1 spos=0 rules=</div><div>2014-02-25 05:13:33,823 [main] TRACE &nbsp; LinkSegment smask=2 rmask=2 name=R2</div><div>2014-02-25 05:13:33,831 [main] TRACE LinkNode notify=true nmask=1 smask=1 spos=0 rules=[RuleMem R1], [RuleMem R2]</div>
<div>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]</div><div>2014-02-25 05:13:33,833 [main] TRACE BetaNode insert=1 stagedInsertWasEmpty=true</div>
<div>2014-02-25 05:13:33,833 [main] TRACE LinkNode notify=true nmask=2 smask=3 spos=0 rules=[RuleMem R1], [RuleMem R2]</div><div>2014-02-25 05:13:33,833 [main] TRACE &nbsp; LinkSegment smask=1 rmask=1 name=R1</div><div>2014-02-25 05:13:33,834 [main] TRACE &nbsp; LinkSegment smask=1 rmask=3 name=R2</div>
<div>2014-02-25 05:13:33,834 [main] TRACE &nbsp; &nbsp; LinkRule name=R2</div><div>2014-02-25 05:13:33,855 [main] TRACE Queue RuleAgendaItem [Activation rule=R2, act#=0, salience=0, tuple=null]</div><div>2014-02-25 05:13:33,856 [main] TRACE Queue Added 1 [Activation rule=R2, act#=0, salience=0, tuple=null]</div>
<div>2014-02-25 05:13:33,856 [main] TRACE Rule[name=R2] segments=2 TupleSets[insertSize=1, deleteSize=0, updateSize=0]</div><div>2014-02-25 05:13:33,856 [main] TRACE &nbsp; &nbsp; &nbsp;1 [JoinNode(5) - [ClassObjectType class=org.drools.compiler.integrationtests.Misc2Test$Foo2]] TupleSets[insertSize=1, deleteSize=0, updateSize=0]</div>
<div>2014-02-25 05:13:33,857 [main] TRACE &nbsp; &nbsp; &nbsp;Segment 0</div><div>2014-02-25 05:13:33,857 [main] TRACE &nbsp; &nbsp; &nbsp;1 [JoinNode(5) - [ClassObjectType class=org.drools.compiler.integrationtests.Misc2Test$Foo2]] TupleSets[insertSize=1, deleteSize=0, updateSize=0]</div>
<div>2014-02-25 05:13:33,865 [main] TRACE &nbsp; &nbsp; &nbsp;rightTuples TupleSets[insertSize=1, deleteSize=0, updateSize=0]</div><div>2014-02-25 05:13:33,867 [main] TRACE &nbsp; &nbsp; &nbsp;Segment 1</div><div>2014-02-25 05:13:33,867 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp;2 [NotNode(9) - [ClassObjectType class=org.drools.compiler.Person]] TupleSets[insertSize=1, deleteSize=0, updateSize=0]</div>
<div>2014-02-25 05:13:33,867 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp;Segment 1</div><div>2014-02-25 05:13:33,868 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp;2 [NotNode(9) - [ClassObjectType class=org.drools.compiler.Person]] TupleSets[insertSize=1, deleteSize=0, updateSize=0]</div>
<div>2014-02-25 05:13:33,868 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp;rightTuples TupleSets[insertSize=0, deleteSize=0, updateSize=0]</div><div>2014-02-25 05:13:33,870 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3 [RuleTerminalNode(10): rule=R2] TupleSets[insertSize=1, deleteSize=0, updateSize=0]</div>
<div>2014-02-25 05:13:33,871 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Segment 1</div><div>2014-02-25 05:13:33,871 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3 [RuleTerminalNode(10): rule=R2] TupleSets[insertSize=1, deleteSize=0, updateSize=0]</div><div>2014-02-25 05:13:33,871 [main] TRACE Fire &quot;R2&quot;&nbsp;</div>
<div>[[ R2 active=false ] [ null</div><div>[fact 0:2:588638666:588638666:2:DEFAULT:NON_TRAIT:org.drools.compiler.integrationtests.Misc2Test$Foo2@2315e9ca]</div><div>[fact 0:1:1668059028:1668059028:1:DEFAULT:NON_TRAIT:org.drools.compiler.integrationtests.Misc2Test$Foo@636c8f94] ] ]</div>
<div>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]</div><div>2014-02-25 05:13:33,879 [main] TRACE &nbsp; LinkSegment smask=1 rmask=1 name=R1</div>
<div>2014-02-25 05:13:33,879 [main] TRACE &nbsp; LinkSegment smask=1 rmask=3 name=R2</div><div>2014-02-25 05:13:33,879 [main] TRACE &nbsp; &nbsp; LinkRule name=R2</div><div>2014-02-25 05:13:33,880 [main] TRACE Insert [fact 0:3:1618732380:-62068830:4:DEFAULT:LEGACY_TRAITABLE:[Person name=&#39;null age=&#39;0&#39; likes=&#39;null&#39;]]</div>
<div>2014-02-25 05:13:33,880 [main] TRACE BetaNode insert=1 stagedInsertWasEmpty=true</div><div>2014-02-25 05:13:33,880 [main] TRACE LinkNode notify=true nmask=1 smask=1 spos=1 rules=[RuleMem R1]</div><div>2014-02-25 05:13:33,880 [main] TRACE &nbsp; LinkSegment smask=2 rmask=3 name=R1</div>
<div>2014-02-25 05:13:33,881 [main] TRACE &nbsp; &nbsp; LinkRule name=R1</div><div>2014-02-25 05:13:33,881 [main] TRACE Queue RuleAgendaItem [Activation rule=R1, act#=2, salience=0, tuple=null]</div><div>2014-02-25 05:13:33,881 [main] TRACE Queue Added 1 [Activation rule=R1, act#=2, salience=0, tuple=null]</div>
<div>2014-02-25 05:13:33,881 [main] TRACE LinkNode notify=true nmask=1 smask=1 spos=1 rules=[RuleMem R2]</div><div>2014-02-25 05:13:33,882 [main] TRACE &nbsp; LinkSegment smask=2 rmask=3 name=R2</div><div>2014-02-25 05:13:33,882 [main] TRACE &nbsp; &nbsp; LinkRule name=R2</div>
<div>2014-02-25 05:13:33,882 [main] TRACE Rule[name=R1] segments=2 TupleSets[insertSize=0, deleteSize=0, updateSize=0]</div><div>2014-02-25 05:13:33,882 [main] TRACE &nbsp; &nbsp; &nbsp;4 [JoinNode(5) - [ClassObjectType class=org.drools.compiler.integrationtests.Misc2Test$Foo2]] TupleSets[insertSize=0, deleteSize=0, updateSize=0]</div>
<div>2014-02-25 05:13:33,883 [main] TRACE &nbsp; &nbsp; &nbsp;Segment 0</div><div>2014-02-25 05:13:33,883 [main] TRACE &nbsp; &nbsp; &nbsp;4 [JoinNode(5) - [ClassObjectType class=org.drools.compiler.integrationtests.Misc2Test$Foo2]] TupleSets[insertSize=0, deleteSize=0, updateSize=0]</div>
<div>2014-02-25 05:13:33,884 [main] TRACE &nbsp; &nbsp; &nbsp;rightTuples TupleSets[insertSize=0, deleteSize=0, updateSize=1]</div><div>2014-02-25 05:13:33,884 [main] TRACE &nbsp; &nbsp; &nbsp;Segment 1</div><div>2014-02-25 05:13:33,884 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp;5 [JoinNode(7) - [ClassObjectType class=org.drools.compiler.Person]] TupleSets[insertSize=0, deleteSize=0, updateSize=1]</div>
<div>2014-02-25 05:13:33,884 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp;Segment 1</div><div>2014-02-25 05:13:33,885 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp;5 [JoinNode(7) - [ClassObjectType class=org.drools.compiler.Person]] TupleSets[insertSize=0, deleteSize=0, updateSize=1]</div>
<div>2014-02-25 05:13:33,885 [main] TRACE &nbsp; &nbsp; &nbsp; &nbsp;rightTuples TupleSets[insertSize=1, deleteSize=0, updateSize=0]</div></div><div><br></div><div>java.lang.NullPointerException</div><div><span style="white-space:pre-wrap">        </span>at org.drools.core.util.index.LeftTupleIndexHashTable.remove(LeftTupleIndexHashTable.java:386)</div>
<div><span style="white-space:pre-wrap">        </span>at org.drools.core.phreak.RuleNetworkEvaluator.doUpdatesReorderLeftMemory(RuleNetworkEvaluator.java:799)</div></div><div><br></div><div><br></div></div></blockquote></div><br>
</div>