I have the following bpmn:
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
targetNamespace="testloop"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:activiti="http://activiti.org/bpmn">
<process id="testloop" name="test loop process" >
<property id="processVariable" itemSubjectRef="xsd:string" name="processVariable"/>
<!– nodes –>
<!– Start Node –>
<startEvent id="start" name="Start" activiti:async="true" />
<!– Sample Tasks –>
<serviceTask id="task1" name="task 1" activiti:class="com.someDelegate" activiti:async="true" />
<serviceTask id="task2" name="task 2" activiti:class="com.someDelegate" activiti:async="true" />
<serviceTask id="looptask" name="loop task" activiti:class="com.someDelegate" activiti:async="true">
<multiInstanceLoopCharacteristics isSequential="false">
<loopCardinality>3</loopCardinality>
</multiInstanceLoopCharacteristics>
</serviceTask>
<serviceTask id="task5" name="task 5" activiti:class="com.someDelegate" activiti:async="true" />
<!– End Node –>
<endEvent id="end" name="End" activiti:async="true"/>
<!– connections –>
<sequenceFlow id="flow1" sourceRef="start" targetRef="task1" />
<sequenceFlow id="flow2" sourceRef="task1" targetRef="task2" />
<sequenceFlow id="flow3" sourceRef="task2" targetRef="looptask" />
<sequenceFlow id="flow8" sourceRef="looptask" targetRef="task5" />
<sequenceFlow id="flow9" sourceRef="task5" targetRef="end" />
</process>
</definitions>
I have an integration test which runs this process and completes each task until the process finishes. I noticed I get the following exception very often:
SEVERE: Error while closing command context
org.activiti.engine.ActivitiObjectNotFoundException: execution 819072 doesn't exist
at org.activiti.engine.impl.cmd.NeedsActiveExecutionCmd.execute(NeedsActiveExecutionCmd.java:48)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
at org.activiti.engine.impl.RuntimeServiceImpl.signal(RuntimeServiceImpl.java:192)
When I looked in my db I found this:
mysql> select ID_,PROC_DEF_ID_,PROC_INST_ID_,EXECUTION_ID_,ACT_ID_ from ACT_HI_ACTINST where PROC_INST_ID_='819059';
+——–+———————————-+—————+—————+———-+
| ID_ | PROC_DEF_ID_ | PROC_INST_ID_ | EXECUTION_ID_ | ACT_ID_ |
+——–+———————————-+—————+—————+———-+
| 819082 | testLoop:1424:819058 | 819059 | 819059 | end |
| 819068 | testLoop:1424:819058 | 819059 | 819067 | looptask |
| 819077 | testLoop:1424:819058 | 819059 | 819073 | looptask |
| 819079 | testLoop:1424:819058 | 819059 | 819074 | looptask |
| 819060 | testLoop:1424:819058 | 819059 | 819059 | start |
| 819063 | testLoop:1424:819058 | 819059 | 819059 | task1 |
| 819065 | testLoop:1424:819058 | 819059 | 819059 | task2 |
| 819081 | testLoop:1424:819058 | 819059 | 819059 | task5 |
+——–+———————————-+—————+—————+———-+
8 rows in set (0.08 sec)
mysql> select ID_,PROC_INST_ID_,EXECUTION_ID_,NAME_,VAR_TYPE_,REV_ from ACT_HI_VARINST where PROC_INST_ID_='819059';
+——–+—————+—————+————————+———–+——+
| ID_ | PROC_INST_ID_ | EXECUTION_ID_ | NAME_ | VAR_TYPE_ | REV_ |
+——–+—————+—————+————————+———–+——+
| 819069 | 819059 | 819067 | nrOfInstances | integer | 0 |
| 819070 | 819059 | 819067 | nrOfCompletedInstances | integer | 3 |
| 819071 | 819059 | 819067 | nrOfActiveInstances | integer | 3 |
| 819075 | 819059 | 819072 | loopCounter | integer | 0 |
| 819076 | 819059 | 819073 | loopCounter | integer | 0 |
| 819078 | 819059 | 819074 | loopCounter | integer | 0 |
+——–+—————+—————+————————+———–+——+
7 rows in set (0.07 sec)
Execution 819072 exists in the ACT_HI_VARINST but not in the ACT_HI_ACTINST table. Of the three concurrent executions, 819072 seems to have been replaced by its parent which is 819067 (my guess). Is this expected behavior? It makes it difficult to handle the above exception and verify whether the execution is null because a db update hasn't been flushed or if the execution no longer exists in Runtime. I was planning on just checking ACT_HI_ACTINST to check this but it seems now I should instead check ACT_HI_VARINST. Does that sound right? Is this not inconsistent data?