Hi, all
I was to suspend an process instance during the execution of a asynchronous service task, but the engine report the following exception:
ExecutionEntity was updated by another transaction concurrently.
I debugged the engine, and find that the SuspendProcessInstanceCmd and the ExecutionJobCmd have different command contexts each of which has a persistence object cache itself.
The SuspendProcessInstanceCmd intend to get the execution entity from its own command context, in case of failure, it create an new ExecutionEntity instance from the database and flush it to the database on the end of the command, while in the same time, there is already an ExecutionEntity in the command context of ExecutionJobCmd. So, when the ExecutionJobCmd flushes the ExecutionEntity, the database would not do the update because it's not consistent with the record in the Execution table.
So I think maybe we can add an shared persistence object cache to each command context stack, and put the ExecutionEntity and other persistence objects that may need to be access by other commands in the shared cache. And all the persistence objects are flushed only by the command context that create it.
Is this scalable?