Bug 1274696 - An expired event deletion fails
Summary: An expired event deletion fails
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: BRE
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ER5
: 6.2.0
Assignee: Mario Fusco
QA Contact: Marek Winkler
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-10-23 12:00 UTC by Marek Winkler
Modified: 2020-03-27 19:05 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2020-03-27 19:05:34 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Marek Winkler 2015-10-23 12:00:27 UTC
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 12:27:39 UTC
PR with reproducer: https://github.com/droolsjbpm/drools/pull/523

Comment 3 Mario Fusco 2015-10-27 17:45:03 UTC
Fixed by https://github.com/droolsjbpm/drools/commit/3e455f3cf

Comment 4 Marek Winkler 2015-11-05 12:26:29 UTC
Verified in BRMS 6.2.0 ER5.


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