Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-4898

Accumulates: min does not work after retracting fact.

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 7.26.0.Final, 7.31.0.Final
    • Fix Version/s: None
    • Component/s: core engine
    • Labels:
    • Sprint:
      2020 Week 01-03 (from Dec 30)
    • Steps to Reproduce:
      Hide

      run attached reproducer by mvn clean test.

      Show
      run attached reproducer by mvn clean test.
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      The following rules does not work with specific facts.

      rule "rule1_long"
          when
              accumulate( Fact( $longVal: longVal), $minVal : min($longVal))
              accumulate( Fact( $longVal2: longVal, $longVal2 > $minVal), $minVal2 : min($longVal2))
      
              $minFact: Fact( longVal == $minVal)
              $minFact2: Fact( longVal == $minVal2)
      
          then
      		System.out.println("Rule ["+kcontext.getRule().getName()+ "] fires!");        
      		Long $diff = (Long)$minVal2 - (Long)$minVal;
      		$minFact2.setDiff($diff);
      //		update($minFact2);
       		String errmsg = $diff == 0?  " !!!!! ERROR !!!!!" : "";
      		System.out.println( drools.getRule().getName() + " diff:" + $minFact2.getLongVal()  + " - " + $minFact.getLongVal() + " = " + $diff + errmsg);
      		System.out.println("\tretract <= "+$minFact );
      		retract($minFact);			
      
      end
      

      There seems to be 2 kind of issues (root cause might be same though).

      • 2nd accumulate return same min value with 1st one.
      • rule fire count is less than expected.

      This does not work with specific set of facts, but works with another set of facts.
      If update is called for the fact like above commented out line, this does not happen.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mfusco Mario Fusco
                  Reporter:
                  hiroko Hiroko Miura
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: