Bug 779582 (SOA-1956)

Summary: Deleting process instances leads to orphaned records in the JBPM_VARIABLEINSTANCE, JBPM_BYTEARRAY, JBPM_BYTEBLOCK tables
Product: [JBoss] JBoss Enterprise SOA Platform 4 Reporter: Martin Weiler <mweiler>
Component: JBPM - within SOAAssignee: Kevin Conner <kevin.conner>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 4.3 CP02   
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
URL: http://jira.jboss.org/jira/browse/SOA-1956
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 779583 (view as bug list) Environment:
Last Closed: 2010-05-31 09:32:07 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:

Description Martin Weiler 2010-02-18 09:39:08 UTC
Date of First Response: 2010-05-12 11:49:52
Help Desk Ticket Reference: https://enterprise.redhat.com/issue-tracker/464703
Workaround Description: * For records where NAME_ = ' ESB_ASYNC_SIGNAL_VARIABLE_ACTOR_':
Remove the <property name="actor" value="FrankSinatra"/> property from the BpmProcessor

* For records related to the 'theBody' variable:
Ensure that the file content is converted into a String before the value is passed into jBPM, for instance by adding the following action before the BpmProcessor (StartProcessInstanceCommand):
<action name="transformFromByteArrayToString" class="org.jboss.soa.esb.actions.converters.ByteArrayToString">
  <property name="encoding" value="UTF-8" />
</action>
project_key: SOA

In order to prevent the jBPM database to keep growing, the jBPM API (GraphSession.deleteProcessInstance) can be called to delete ended process instances. After inspecting the tables, however, there is data which is not cleaned up. This can easily be reproduced with the quickstarts:

1. Run the bpm_orchestration1 quickstart
2. Using the jbpm-console app, delete the ended process instance
3. Inspect the jBPM tables, the following tables hold records which should actually have been deleted:

JBPM_VARIABLEINSTANCE
JBPM_BYTEARRAY
JBPM_BYTEBLOCK

Looking at the JBPM_VARIABLEINSTANCE table, there are two types of records left:
1. ESB_ASYNC_SIGNAL_VARIABLE_ACTOR_ (String) variable
2. theBody (ByteArray) variable, which is referencing records in the JBPM_BYTEARRAY and JBPM_BYTEBLOCK table

For #1, this variable is being created by the ESB when the 'actor' property on the BpmProcessor is defined, but loses the relation to the token, and will therefore not being cleared up. This needs to be addressed in the ESB code, but a workaround is to not use the 'actor' property.

For #2, this comes from how the bpm_orchestrationX quickstarts are set up, starting with a file gateway that kicks of the jBPM process. As the file content is placed as byte array, that's how the 'theBody' variable will be created initially. In the course of the other ESB actions, this variable will be updated by a String representation of the content. Hibernate will, however, not update the initial variable instance, but rather create a new one. To get around this, ensure that the variable type does not change.

Comment 1 Kevin Conner 2010-05-04 13:44:35 UTC
Link: Added: This issue depends JBESB-3301


Comment 2 Kevin Conner 2010-05-12 15:49:52 UTC
The ESB/jBPM async job will now delete the VariableInstances used as part of that communication, although this can only work when jBPM logging is *not* enabled.

The quickstart has also been changed to use a message composer, creating Strings rather than byte[] payloads.

Updated in ESB codebase, will be in next merge.

Comment 3 Alejandro Guizar 2010-05-17 21:35:37 UTC
Link: Added: This issue incorporates JBPM-2828


Comment 4 Alejandro Guizar 2010-05-17 21:56:29 UTC
JBPM-2828 fixes the very issue that JBESB-3301 works around: delete the variable instances *iff* logging is not enabled. This could lead to executing duplicate and conflicting delete statements. Is JBESB-3301 still necessary even with jBPM 3.2.9?

Comment 5 Kevin Conner 2010-05-18 08:39:51 UTC
Part of the fix will be necessary, for example the change in the quickstart and the reworked deletion of the variables.

The only part which may no longer be necessary is the explicit hibernate delete of the variable instance.

BTW Where is the SOA issue for JBPM-2828?

Comment 6 Kevin Conner 2010-05-18 16:56:48 UTC
The explicit hibernate deletion of the variable instance has now been removed from the ESB codebase.

Comment 7 Alejandro Guizar 2010-05-18 17:24:28 UTC
Link: Removed: This issue incorporates JBPM-2828 


Comment 8 Alejandro Guizar 2010-05-18 17:25:10 UTC
Link: Added: This issue related SOA-1995


Comment 9 Jiri Pechanec 2010-05-31 09:32:07 UTC
Verified in CR1

Comment 10 David Le Sage 2010-06-06 23:11:35 UTC
Here is the draft text for the Release Notes:



https://jira.jboss.org/browse/JBESB-3301

    In order to prevent the jBPM database from growing to unmanageable sizes, the
    GraphSession.deleteProcessInstance is able to delete ended process instances.
    However, this functionality was not working correctly, meaning that some legacy data was left
    "orphaned" in the tables. This happened because only the references to the process execution
    were removed, not the variables themselves.

    To fix this problem, variable instances are now deleted if logging is not enabled. If the
    logging service is enabled, the variable cannot be deleted immediately becauses the new
    VariableDeleteLog instance holds a reference to the variable. (These records are eventually
    removed upon process instance deletion.) As a result of this fixed, there are no longer orphaned
    files in the database.