Flowable Optimistic Locking Exception for- suspend,cancel and resume actions

Hi Team,

im developing a springboot application to process inputs.

@controller class consists of 4 end points

1.createProcess()
this end point is to start the process , input file will be passed as parameter
i have 20 + service task defined in bpmn.xml, made all service task “flowable:async=“true”

2.suspendProcess()
this end point is to suspend the process , processInstanceId passed as param parameter

3.activateProcess()
this end point is to activate the suspended process , processInstanceId passed as param parameter

4.cancelProcess()
this end point is to cancel the process , processInstanceId passed as param parameter

one @service class created to process above all 4 requests.
flowable RuntimeService is autowired in this class.

there is no issues with 1.createProcess() end point. able to start the process

but when rquest reaches to other end points im getting below exception.

org.flowable.common.engine.api.FlowableOptimisticLockingException: Execution[ id ‘09f7f5fd-676e-11ea-b9c2-0050568e1cce’ ] - activity ‘phase2-execute’ - parent ‘09f732a4-676e-11ea-b9c2-0050568e1cce’ was updated by another transaction concurrently

im not able to suspend or cancel or activate the suspended process.

kindly help me to resolve this issue.

Thanks
Am

This most likely means that at the time of suspending, the process instance is executing an async job. It takes a lock on the process instance and hence why this exception is being returned.

There’s not much to do about this: once the job is being executed, it will run until it’s done. A very simple solution could be a simple retry loop in your suspend logic. A more advanced solution could be to make the suspending an async job too, which means it’ll automatically be retried.