cancel
Showing results for 
Search instead for 
Did you mean: 

ACT_HI_ACTINST inconsistent with ACT_HI_VARINST

jorell
Champ in-the-making
Champ in-the-making
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?
4 REPLIES 4

jorell
Champ in-the-making
Champ in-the-making
Anyone? Please let me know if it doesn't make sense or if I can provide more info on this. From the looks of it seems like a bug in activiti but I would like someone more experienced to comment on it.

jbarrez
Star Contributor
Star Contributor
From the stacktrace, isee you are doing a signal:

<code>
at org.activiti.engine.impl.RuntimeServiceImpl.signal(RuntimeServiceImpl.java:192)
</code>

A signal is always on the RUNTIME data, never on ACT_HI_VARINST nor on ACT_HI_ACTINST

jorell
Champ in-the-making
Champ in-the-making
Thanks for your reply. Yes I understand that a signal is on runtime data. I was merely explaining the error that led me to look at the History tables. When I was signaling and I got the error message saying that the execution does not exist, I looked at the history table to see if it ever existed in the past. For the purpose of this thread you may ignore that error message.
My main question is how can an execution exist in ACT_HI_VARINST but not in the ACT_HI_ACTINST. You can view the above queries for specific example of what I mean.

jbarrez
Star Contributor
Star Contributor
Ok, now i understand your question: what you see here is correct: when the multi instance is entered, child executions are created for each of the instances such that variables can be scoped.

The activity is entered however by the parent of that execution, hence why you see an execution for your variable that is different. It is actually the child of the one which enters the activity.