This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 975092 - Fork/Join with async nodes and variable updates fails
Fork/Join with async nodes and variable updates fails
Status: VERIFIED
Product: JBoss Enterprise SOA Platform 5
Classification: JBoss
Component: JBPM - standalone, JBPM - within SOA (Show other bugs)
5.3.1
Unspecified Unspecified
high Severity high
: GA
: ---
Assigned To: Shelly McGowan
:
Depends On:
Blocks: 986007
  Show dependency treegraph
 
Reported: 2013-06-17 11:47 EDT by Martin Weiler
Modified: 2016-09-20 01:09 EDT (History)
3 users (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)
Added stack trace (from support case). (3.28 KB, text/plain)
2013-06-25 13:31 EDT, Marco Rietveld
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker JBPM-4031 Major Resolved Fork/Join with async nodes and variable updates fails 2015-05-15 08:25:20 EDT

  None (edit)
Description Martin Weiler 2013-06-17 11:47:59 EDT
Description of problem:
Platform issue for JBPM-4031
Comment 1 JBoss JIRA Server 2013-06-18 10:28:39 EDT
Martin Weiler <mweiler@redhat.com> made a comment on jira JBPM-4031

Proposal to fix this issue:

{code}
diff --git a/core/src/main/resources/org/jbpm/context/exe/ContextInstance.hbm.xml b/core/src/main/resources/org/jbpm/context/exe/ContextInstance.hbm.xml
index 300a612..d0fd5ab 100644
--- a/core/src/main/resources/org/jbpm/context/exe/ContextInstance.hbm.xml
+++ b/core/src/main/resources/org/jbpm/context/exe/ContextInstance.hbm.xml
@@ -10,7 +10,7 @@
             extends="org.jbpm.module.exe.ModuleInstance" 
             discriminator-value="C">
   
-    <map name="tokenVariableMaps" cascade="all" inverse="true">
+    <map name="tokenVariableMaps" cascade="all" inverse="true" optimistic-lock="false">
       <!-- add on-delete for optimized deletion 
       <key column="CONTEXTINSTANCE_" on-delete="cascade" />
       -->
{code}

This fix prevents the ContextInstance version to be incremented during the update of the TokenVariableMap. As a result, the process execution is no longer failing with a race condition.

But there is a caveat: if all nodes inside the fork/join are async with no wait states, the parent node will not be signaled automatically out of the join when all child tokens arrive.
Comment 2 Marco Rietveld 2013-06-25 13:31:47 EDT
Created attachment 765213 [details]
Added stack trace (from support case).
Comment 5 JBoss JIRA Server 2013-06-26 11:00:17 EDT
Marco Rietveld <marco.rietveld@redhat.com> made a comment on jira JBPM-4031

I've looked at a bunch of different hibernate 3 mapping options, and started to look at possible hibernate session tricks (tx synchs? session.refresh()?), but luckily, I ran into JBPM-2948, which Brad Davis implemented. 

One possible solution for this user would be to implement his process using the functionality described there, which basically means using async subprocesses instead of async nodes. I'll let you know when I have a working test for this.
Comment 6 JBoss JIRA Server 2013-07-10 03:02:09 EDT
Toshiya Kobayashi <tkobayas@redhat.com> made a comment on jira JBPM-4031

Hi Marco,

How about this fix? (attached as JBPM-4031.patch)

{code:java}
diff --git a/core/src/main/java/org/jbpm/context/exe/ContextInstance.java b/core/src/main/java/org/jbpm/context/exe/ContextInstance.java
index 322ae11..c15b4a6 100644
--- a/core/src/main/java/org/jbpm/context/exe/ContextInstance.java
+++ b/core/src/main/java/org/jbpm/context/exe/ContextInstance.java
@@ -330,7 +330,7 @@ public class ContextInstance extends ModuleInstance {
     return tokenVariableMap;
   }
 
-  private TokenVariableMap createTokenVariableMap(Token token) {
+  public TokenVariableMap createTokenVariableMap(Token token) {
     if (tokenVariableMaps == null) {
       tokenVariableMaps = new HashMap();
     }
diff --git a/core/src/main/java/org/jbpm/graph/node/Fork.java b/core/src/main/java/org/jbpm/graph/node/Fork.java
index 026443c..7229be4 100644
--- a/core/src/main/java/org/jbpm/graph/node/Fork.java
+++ b/core/src/main/java/org/jbpm/graph/node/Fork.java
@@ -115,6 +115,8 @@ public class Fork extends Node {
       if( ! parentChildTokens.containsKey(transitionName)) { 
         parentChildTokens.put(transitionName, childToken);
       }
+      // JBPM-4031 : Create TokenVariableMap for each child token beforehand
+      executionContext.getContextInstance().createTokenVariableMap(childToken);
     }
 
     // phase three: branch child tokens from the fork into the transitions
{code}

I have verified it with JBPM4031Test.testVariablesAfterFork() and manual test in SOA-P 5.3.1.
Comment 7 JBoss JIRA Server 2013-07-10 03:04:18 EDT
Toshiya Kobayashi <tkobayas@redhat.com> made a comment on jira JBPM-4031

ContextInstance.getOrCreateTokenVariableMap() is not useful in this case because it returns TokenVariableMap of its parent token. So I use createTokenVariableMap() instead.
Comment 8 JBoss JIRA Server 2013-07-18 16:58:36 EDT
Marco Rietveld <marco.rietveld@redhat.com> made a comment on jira JBPM-4031

I've applied to the patch to the code and tested it. It's good!
Comment 10 JBoss JIRA Server 2013-07-18 16:59:57 EDT
Marco Rietveld <marco.rietveld@redhat.com> updated the status of jira JBPM-4031 to Resolved

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