cancel
Showing results for 
Search instead for 
Did you mean: 

ActivitiOptimisticLockingException on even the simplest process

jbrazil5
Champ in-the-making
Champ in-the-making
Activiti Version : 5.13
Database : MySQL

Hello Activiti Team!

I am still learning about Activiti so sorry if this is a dumb question…

I am trying to understand why I am receiving this exception. This only happens when I have jobExecutorActivate set to "true" in the config. Just another note, this happens in a unit test and also when I attempt to run a process normally(no unit test).

When I run any process where I have async=true on a task this exception gets thrown and the process never completes :


Exception in thread "pool-1-thread-1" org.activiti.engine.ActivitiOptimisticLockingException: JobEntity [id=55933] was updated by another transaction concurrently
   at org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation.execute(DbSqlSession.java:229)
   at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:575)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:443)
   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.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)


This happens even for a process with just start, script, and end task. When I take off the async=true on the script task it works fine.

I think I don't really understand what exactly the jobExecutorActivate does, and if I need it or not. I am not using any timers and in the user guide it says that jobExecutorActivate needs to be on for timers to work. Do I need it to run async processes as well? Can someone explain the basics to me?

Thank you
10 REPLIES 10

trademak
Star Contributor
Star Contributor
This exception will only happen if you have multiple Activiti Engines with the job executor activated. Because then they both retrieve the same job, but only one job executor will "win" and execute the job. Can you check if you have only one Activiti Engine running. If so please create a unit test project so we can reproduce it.

Best regards,

jbrazil5
Champ in-the-making
Champ in-the-making
I don't think I have multiple engines running. Could the issue be that I have multiple engines pointed at the same database? I have one database that I point all of my applications servers to. Does Activiti not support this configuration?

brianok
Champ in-the-making
Champ in-the-making
I have this issue in 5.14 and I am using multiple engines.  I am confused because a quick search seems to insinuate that clustering is not an issue.  Maybe I haven't just read enough old threads yet, but is there a magic setting because right now it seems to be hanging up my subprocesses.  I'll keep reading, but if you have any pointers, that would be useful. 

Thanks in advance, 
Brian

References:
http://forums.activiti.org/content/clustering
http://forums.activiti.org/content/could-multiple-activiti-engines-share-one-repository
http://forums.activiti.org/content/can-two-process-engines-run-same-database

Error:
org.activiti.engine.ActivitiOptimisticLockingException: VariableInstanceEntity[id=3272, name=nrOfCompletedInstances, type=integer, longValue=208, textValue=208] was updated by another transaction concurrently
        at org.activiti.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:562)
        at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:444)
        at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:170)
        at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:117)
        at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66)
        at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
        at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131)
        at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
        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:188)
        at org.activiti.camel.ActivitiProducer.signal(ActivitiProducer.java:95)
        at org.activiti.camel.ActivitiProducer.process(ActivitiProducer.java:60)
        at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)

brianok
Champ in-the-making
Champ in-the-making
Sorry, I should clarify that even though I am running multiple engines, this also seems to be happening in a single engine instance where I am running multi-instance over a collection (sequential = false).

jbrazil5
Champ in-the-making
Champ in-the-making
Is it possible that if one of my included libraries(using maven, including multiple libraries that are dependent on Activiti) also has an activiti.cfg.xml a second engine is being created without my knowledge?

martin_grofcik
Confirmed Champ
Confirmed Champ

slav
Champ in-the-making
Champ in-the-making
Hello,

I'm sorry for posting to such an old topic, but have you come to any conclusion afterwards?
I am now facing pretty much the same problem.

I am updating Activiti version from 5.8 to 5.15.1 in an old Spring application, and now I'm getting this error in multiple test cases:
<blockcode>
16:25:47.527 ERROR [pool-1-thread-1] [ExecuteJobsRunnable] exception during job execution: JobEntity [id=67] was updated by another transaction concurrently
org.activiti.engine.ActivitiOptimisticLockingException: JobEntity [id=67] was updated by another transaction concurrently
at org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation.execute(DbSqlSession.java:272) ~[activiti-engine-5.15.1.jar:5.15.1]
at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:635) ~[activiti-engine-5.15.1.jar:5.15.1]
at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:503) ~[activiti-engine-5.15.1.jar:5.15.1]
at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:175) ~[activiti-engine-5.15.1.jar:5.15.1]
at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:122) ~[activiti-engine-5.15.1.jar:5.15.1]
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66) ~[activiti-engine-5.15.1.jar:5.15.1]
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47) ~[activiti-spring-5.15.1.jar:5.15.1]
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131) ~[spring-tx-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45) ~[activiti-spring-5.15.1.jar:5.15.1]
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31) ~[activiti-engine-5.15.1.jar:5.15.1]
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40) ~[activiti-engine-5.15.1.jar:5.15.1]
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35) ~[activiti-engine-5.15.1.jar:5.15.1]
at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:52) ~[activiti-engine-5.15.1.jar:5.15.1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_72]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_72]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_72]
</blockcode>

I'm almost sure, that I have only one Activiti Engine running (unless there is any configuration option, in which you can set amount of running instances, which I'm not aware of).

I've checked many threads on this forum, but found no solution that would work in my case.

Please let me know, if there's any known commonly made mistake, or any version migration guidelines that might help me.

Thank you.

trademak
Star Contributor
Star Contributor
Do you have a parallel gateway or multi instance in your process definition? We've revised the job executor quite a bit in 5.17.0, so you might want to read up in the user guide there.

Best regards,

slav
Champ in-the-making
Champ in-the-making
Yes, I have parallel gateways in the process.

The reason why I don't use 5.17.0 is that I'd rather avoid Spring 4.0 in my Maven dependencies.

Anyway, I have tried to use 5.17.0, and I got the following stack trace:
<blockcode>
13:41:34.119 ERROR [pool-1-thread-3] [ExecuteJobsRunnable] exception during job execution: ProcessInstance[18] was updated by another transaction concurrently
org.activiti.engine.ActivitiOptimisticLockingException: ProcessInstance[18] was updated by another transaction concurrently
at org.activiti.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:783) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:594) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:211) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:137) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47) ~[activiti-spring-5.17.0.jar:5.17.0]
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131) ~[spring-tx-3.2.2.RELEASE.jar:3.2.2.RELEASE]
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45) ~[activiti-spring-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35) ~[activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.handleMultipleJobs(ExecuteJobsRunnable.java:94) [activiti-engine-5.17.0.jar:5.17.0]
at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:49) [activiti-engine-5.17.0.jar:5.17.0]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_72]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_72]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_72]
</blockcode>

So it seems, that there is still a problem in my process.

I just started using Activiti several days ago, so maye I have some basic mistakes in my process. Is there any change since 5.8, that might cause such problems?

Thank you.
Best regards,

EDIT:
It looks like using AsyncExecutor helps with this error.
I must still investigate, why some test cases fail, but it seems, that the cause is different now.

If I just may ask for one clarification: using AsyncExecutor will not change the outcome of the process - is that right?