Bug 1118449 - Incorrect serialization of Drools STREAM KieSession with expirable events causes NPE
Summary: Incorrect serialization of Drools STREAM KieSession with expirable events cau...
Keywords:
Status: VERIFIED
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: BRE
Version: 6.0.2
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ER1
: ---
Assignee: Mario Fusco
QA Contact: Radovan Synek
URL:
Whiteboard:
: 1130937 (view as bug list)
Depends On:
Blocks: 1115481 1118828 1115479 1130937
TreeView+ depends on / blocked
 
Reported: 2014-07-10 18:06 UTC by Alessandro Lazarotti
Modified: 2018-12-06 17:17 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Fixed Issues Summary: When running a stateful KieSession in STREAM mode and using events with @expires annotations, an invalid serialized session would occur in BRMS. Accordingly, when inserting an event with an @expires annotation and explicitly retracting that Event again from the engine (for example, KieSession.delete), users would receive an invalid serialized session. When users later deserialized the session and immediately serialized it again, they would receive a NPE at the following location: org.drools.core.reteoo.ObjectTypeNode$ExpireJobContextTimerOutputMarshaller.serialize(ObjectTypeNode.java:669) If they deserialized the session and then advanced the pseudo clock to a moment where the original event should have expired, they would receive an NPE at the following location: org.drools.core.common.AbstractWorkingMemory$WorkingMemoryReteExpireAction.execute(AbstractWorkingMemory.java:1524) Therefore, when the Event was explicitly retracted with KieSession.delete(Event), it was removed from the WM but the Expiry Timer Job was not. That Expiry Timer Job was serialized with a "null" fact handle, which did not cause issues with deserialization; however, the next serialization of the session or triggering of the expire action (such as moving the pseudo clock) would trigger the issue. This issue has now been fixed for BRMS 6.0.3.
Clone Of:
: 1118828 1130937 (view as bug list)
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
JBoss Issue Tracker DROOLS-551 Critical Resolved Incorrect serialization of Drools STREAM KieSession with expirable events causes NPE 2016-10-14 13:26:25 UTC

Description Alessandro Lazarotti 2014-07-10 18:06:00 UTC
Platform BZ for Jira https://issues.jboss.org/browse/DROOLS-551


There is an issue in Drools 6, both in PHREAK and RETEOO mode, which causes NPEs to be thrown when a session is serialized and deserialized.
The problem occurs when running a stateful KieSession in STREAM mode and using Events with @expires annotations. When you insert an event with an @expires annotation, and you explicitly retract that Event again from the engine (i.e. KieSession.delete), and after that serialize the session, you end up with an invalid serialized session.

When you later deserialize the session, and immediately serialize it again, a NPE is thrown at: org.drools.core.reteoo.ObjectTypeNode$ExpireJobContextTimerOutputMarshaller.serialize(ObjectTypeNode.java:669). When you deserialize the session and then advance the pseudo clock to a moment where the original event (which we've already retracted from the working memory) should have expired, a NPE is thrown at: org.drools.core.common.AbstractWorkingMemory$WorkingMemoryReteExpireAction.execute(AbstractWorkingMemory.java:1524)

So, it seems that when the Event is explicitly retracted with KieSesion.delete(event), the event is removed from the WM, but the Expiry Timer Job is not. That ExpiryJob gets serialized with a 'null' fact handle, which does not give issues on de-serialization, but on the next serialization of the session, or when an action is peformed that triggers the expire action (i.e. move the pseudo-clock).

A reproducer can be found here: http://www.github.com/DuncanDoyle/DroolsSerializationIssue . To reproduce:

    git clone http://www.github.com/DuncanDoyle/DroolsSerializationIssue
    cd DroolsSerializationIssue/DroolSerializationIssue
    mvn clean test -P phreak (runs the test with Drools in PHREAK mode)
    mvn clean test -P reteoo (runs the test with Drools in RETEOO mode)

In both modes 2 of the 3 tests produce an NPE.

Comment 2 Mario Fusco 2014-07-11 06:44:45 UTC
Fixed by https://github.com/droolsjbpm/drools/commit/ccd415f20

Comment 4 Mario Fusco 2014-07-11 13:47:37 UTC
Cherry-picked to 6.0.x with https://github.com/droolsjbpm/drools/commit/7b1331c26

Comment 5 Lukáš Petrovický 2014-08-21 13:50:34 UTC
This is to be fixed in 6.0.3. It is the original issue to bug 1130937, which I will close as duplicate.

Comment 6 Lukáš Petrovický 2014-08-21 13:51:28 UTC
*** Bug 1130937 has been marked as a duplicate of this bug. ***

Comment 7 Radovan Synek 2014-08-27 13:23:33 UTC
Verified with BRMS-6.0.3.ER1


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