cancel
Showing results for 
Search instead for 
Did you mean: 

ActivitiOptimisticLockingException when suspend ProcessInstance

fritz128
Champ in-the-making
Champ in-the-making
What I have:
I have workflow:
start = > [Main process] => [async Subprocess] => [Main Process] => end

What a problem:
When I suspend Main Process by runtimeservice.suspendProcessInstanceById, program throws exception:

Exception in thread "pool-1-thread-2" org.activiti.engine.ActivitiOptimisticLockingException: ConcurrentExecution[25] was updated by another transaction concurrently
   at org.activiti.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:560)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:442)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:169)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:116)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:70)
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:37)
   at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:46)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   at java.lang.Thread.run(Thread.java:724)


P.S.
At the moment when happens runtimeservice.suspendProcessInstanceById  is proceeding servicetask of the subprocess.
6 REPLIES 6

fritz128
Champ in-the-making
Champ in-the-making
One additional notion about how it happens:
runtimeservice.suspendProcessInstanceById flush all changes into  db, including ConcurrentExecution object. But then each async subprocess try to flush the same values.

trademak
Star Contributor
Star Contributor
Could you create a unit test and create a JIRA (with the unit test as attachment)?

Best regards,

fritz128
Champ in-the-making
Champ in-the-making
Do you check the demo below?

fritz128
Champ in-the-making
Champ in-the-making
I've wrote a simple demo (only a few dozens of lines) that illustrates my problem
git clone https://github.com/JOLO-/ActivitiOptimisticLockingException-during-suspension.git

P.S.
1. Seems I've no rights to create an issue.
2. Not sure that I've understood you properly when you ask me to write a unit test. Is my demo an unit test?

frederikherema1
Star Contributor
Star Contributor
This is just how optimistic locking works… If another thread is running the service-task, and you suspend the process, either the suspend-action OR the commit of the "completed service-task" will get an exception and roll back. That's just the way it works

Thank you a lot!