OptimisticLockingException: ENGINE-03005 when starting a process trhough REST

We’re interacting with camunda engine through the REST API and we’re getting periodic Optimistic Locking exceptions when starting the process. I’m not sure how this can happen, as I understand that starging a process is not a multi-thread operation.

This is the exception we got:

WARNING [http-nio-8080-exec-1] org.camunda.commons.logging.BaseLogger.logWarn ENGINE-REST-HTTP500 org.camunda.bpm.engine.rest.exception.RestException: Cannot instantiate process definition doacandidate:4:fa812260-ac0a-11ec-90a5-86637613f886: ENGINE-03005 Execution of 'UPDATE ExecutionEntity[2bb8f0fa-aa0d-11ec-8c18-621656be675d]' failed. Entity was updated by another transaction concurrently.
	at org.camunda.bpm.engine.rest.sub.repository.impl.ProcessDefinitionResourceImpl.startProcessInstance(ProcessDefinitionResourceImpl.java:131)
	at jdk.internal.reflect.GeneratedMethodAccessor1035.invoke(Unknown Source)

The Entity ID is not to be found in the database.

The process we try to start is similar to:

It fails both when it goes towards subprocess 1 or subprocess 2.

We’re not using asynchronous continuations

Any idea on this?

Could you post the file that you’re using to reproduce?

Often the cause is a duplicated link between two elements (eg. between the “Process Started” and “Process” or betwen the unnamed start and “throw message”). If there’s a duplicated link, the tokens will be multiplied, so you’ll end up with things happening more often than you wanted.

There is no duplicated links that I can find, however the problem might be related to the fact of having 3 listeners on the start of the process that set the values of 3 variables:
image
Do you think this might be the root cause of the exception as this might have some concurrent updates in the database? If that is the case, is there a better way to initialize the variable values?

I wouldn’t think so, as they should be communicating with the execution engine, which then writes to the DB at the next async.

Are you able to reproduce it with a anonymous example process that you could then post?