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.
PR with reproducer: https://github.com/droolsjbpm/drools/pull/523
Fixed by https://github.com/droolsjbpm/drools/commit/3e455f3cf
Verified in BRMS 6.2.0 ER5.