Bug 1032059

Summary: RETE-OO: Reversed live query results order compared to PHREAK
Product: [Retired] JBoss BRMS Platform 6 Reporter: Marek Winkler <mwinkler>
Component: BREAssignee: Edson Tirelli <etirelli>
Status: CLOSED NOTABUG QA Contact: Marek Winkler <mwinkler>
Severity: low Docs Contact:
Priority: unspecified    
Version: 6.0.0CC: mproctor
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-11-19 14:53:39 UTC 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:
Attachments:
Description Flags
Maven project with reproducer none

Description Marek Winkler 2013-11-19 13:25:58 UTC
Created attachment 826055 [details]
Maven project with reproducer

Description of problem:

Live queries return results in different order with PHREAK and with RETE. 

For instance, imagine you define a live query (KieSession.openLiveQuery()) which returns two rows, A and B. If you attach a ViewChangedEventListener to the query, the ViewChangedEventListener.rowInserted(Row) method gets called as follows:

PHREAK: 
  ViewChangedEventListener.rowInserted(A), 
  ViewChangedEventListener.rowInserted(B)

RETEOO:
  ViewChangedEventListener.rowInserted(B),
  ViewChangedEventListener.rowInserted(A)

I am not sure if this is by design or a bug, or just the order of query results is not guaranteed in general.

Could someone from engineering comment this?

Version-Release number of selected component (if applicable):

Drools 6.0.0-SNAPSHOT
BRMS 6.0.0 ER4

How reproducible:

Run LiveQueriesTest from the attached Maven project with setting drools engine to RETE:

mvn clean test -Dtest=LiveQueriesTest -Ddrools.ruleEngine=reteoo

The query results order is reversed when executed with PHREAK:

mvn clean test -Dtest=LiveQueriesTest -Ddrools.ruleEngine=phreak

Comment 2 Mark Proctor 2013-11-19 14:51:33 UTC
There is no guarantee on the order the rows will be produced for a single rule. This is something that has and will change over time, as we optimise internal data structures. It's even changed between ReteOO versions.