Bug 1274696 - An expired event deletion fails
An expired event deletion fails
Status: VERIFIED
Product: JBoss BRMS Platform 6
Classification: JBoss
Component: BRE (Show other bugs)
6.2.0
Unspecified Unspecified
high Severity high
: ER5
: 6.2.0
Assigned To: Mario Fusco
Marek Winkler
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-10-23 08:00 EDT by Marek Winkler
Modified: 2015-11-05 07:26 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Marek Winkler 2015-10-23 08:00:27 EDT
Description of problem:

Having the following rule:

declare Event
    @role( event )
    id : long
end

declare Absence
    id : long
end

rule "detect absence"
when
	$event : Event(  )
    not (
        Event(
            this != $event,
            id == $event.id,
            this after[0ms, 3100ms] $event
        )
    )
    not (Absence( 
            id == $event.id
    	)
    )
then
    delete($event)
    insert(new Absence($event.id))
end

and the following sequence of commands:

  session.insert(eventFactType.newInstance());
  session.fireAllRules();
  clock.advanceTime(3300, TimeUnit.MILLISECONDS);
  session.fireAllRules();

The evaluation of rule's consequence fails with the following exception:

  org.kie.api.runtime.rule.ConsequenceException: Exception executing consequence for rule "detect absence" in org.jboss.qa.brms.bre.regression: [Error: delete($event): Update error: handle not found for object: Event( id=0 ). Is it in the working memory?]
[Near : {... delete($event); ....}]
             ^
[Line: 1, Column: 1]
	at org.drools.core.base.DefaultKnowledgeHelper.getFactHandle(DefaultKnowledgeHelper.java:383)
...

The problem seems to be that the event expires before the rule consequence is executed and the delete() command fails. This indeed makes sense; however, since this test-case passed with BRMS 6.1.x, I would like to make sure that this change in behavior is intended and not a bug. Could you please confirm?

If this is intended, is there a way how to delete a fact "safely", i.e. that would delete the fact only if it actually is present in WM at the time when the delete is called?

An interesting fact (for me) is that when you remove the first session.fireAllRules() call, the exception does not occur.

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

How reproducible:
always

Steps to Reproduce:
I will attach a PR with reproducer, if needed.

Actual results:
Fact deletion fails because the event has already expired.

Expected results:
Not sure if this is the expected behavior or not.
Comment 1 Marek Winkler 2015-10-23 08:27:39 EDT
PR with reproducer: https://github.com/droolsjbpm/drools/pull/523
Comment 3 Mario Fusco 2015-10-27 13:45:03 EDT
Fixed by https://github.com/droolsjbpm/drools/commit/3e455f3cf
Comment 4 Marek Winkler 2015-11-05 07:26:29 EST
Verified in BRMS 6.2.0 ER5.

Note You need to log in before you can comment on or make changes to this bug.