With conditions below:
- Parent/Sub process
- Start a parent process instance
- Sub process is started by CallActivity
- Reached to a Human Task in the sub process. Tx Committed
- Load the parent process with getProcessInstance(parentProcessInstanceId, true) // readOnly = true
- Complete the Task in the sub process
- Sub process is completed
- Parent process instance is resumed
- Reached to a Human Task in the parent process. Tx Committed
Parent ProcessInstance is not correctly persisted at the last step. For example, process variable is not updated.
By debugging, I found that:
- If you load a process instance with readOnly = true for the first time in the transaction, it will be stored in JPAProcessInstanceManager.processInstances
- Then, if the same process instance is loaded with readOnly = false (e.g. a parent process instance is signaled on sub process completion), JPAProcessInstanceManager.getProcessInstance() will find the processInstance from "processInstances" cache.
- processInstance.isPersisted() is false at that moment. So TransactionManagerHelper.addToUpdatableSet() is not called
- So the process instance is not listed in "toBeUpdated" in TriggerUpdateTransactionSynchronization.beforeCompletion() so ProcessInstanceInfo.transform() is not called.