Problems with business key constraint in wait states

Hi,
I am trying to start multiple process instances of a process definition. The definition contains a timer wait event. I have applied the unique business key constraint in the database.

When I start a single process instance, it works fine. But, when I start multiple instances, if multiple instances are present in the same wait state, the engine gives me an error regarding the unique business key constraint. I’ve added the stacktrace below. I am using Camunda starter with version 7.14

I’ve also attached the workflow. The issue I described is in the timer event.

org.camunda.bpm.engine.ProcessEngineException: An exception occurred in the persistence layer. Please check the server logs for a detailed message and the entire exception stack trace.
at org.camunda.bpm.engine.impl.util.ExceptionUtil.wrapPersistenceException(ExceptionUtil.java:263)
at org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.flushDbOperationException(EnginePersistenceLogger.java:132)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperations(DbEntityManager.java:364)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperationManager(DbEntityManager.java:323)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flush(DbEntityManager.java:295)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:272)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:188)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:119)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:46)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:44)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70)
at org.camunda.bpm.engine.impl.interceptor.CommandCounterInterceptor.execute(CommandCounterInterceptor.java:35)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:57)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.executeJob(ExecuteJobsRunnable.java:110)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:71)
at org.springframework.cloud.sleuth.instrument.async.TraceRunnable.run(TraceRunnable.java:67)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: org.camunda.bpm.engine.ProcessEngineException: ENGINE-03004 Exception while executing Database Operation ‘INSERT ExecutionEntity[c5a7444a-3602-11eb-bd6a-00505683cc8f]’ with message ’

Error flushing statements. Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.insertExecution (batch index #5) failed. 4 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: ORA-00001: unique constraint (SIWORKFLOW.ACT_UNIQ_RU_BUS_KEY) violated

Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.insertExecution (batch index #5) failed. 4 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: ORA-00001: unique constraint (SIWORKFLOW.ACT_UNIQ_RU_BUS_KEY) violated

java.sql.BatchUpdateException: ORA-00001: unique constraint (SIWORKFLOW.ACT_UNIQ_RU_BUS_KEY) violated

java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (SIWORKFLOW.ACT_UNIQ_RU_BUS_KEY) violated

'. Flush summary:
[
INSERT HistoricVariableInstanceEntity[c5a6f628-3602-11eb-bd6a-00505683cc8f]
INSERT HistoricJobLogEventEntity[c5a7926d-3602-11eb-bd6a-00505683cc8f]
INSERT HistoricVariableUpdateEventEntity[c5a6f629-3602-11eb-bd6a-00505683cc8f]
INSERT HistoricActivityInstanceEventEntity[Event_0afxzf7:c5a7444c-3602-11eb-bd6a-00505683cc8f]
INSERT HistoricActivityInstanceEventEntity[ProvisioningAPI:c5853d57-3602-11eb-bd6a-00505683cc8f]
INSERT ExecutionEntity[c5a7444a-3602-11eb-bd6a-00505683cc8f]
INSERT VariableInstanceEntity[c5a6f628-3602-11eb-bd6a-00505683cc8f]
INSERT EventSubscriptionEntity[c5a7444b-3602-11eb-bd6a-00505683cc8f]
DELETE MessageEntity[c50f70ff-3602-11eb-bd6a-00505683cc8f]
DELETE_BULK deleteByteArrayNoRevisionCheck c548a97b-3602-11eb-bd6a-00505683cc8f
UPDATE ExecutionEntity[c50e8682-3602-11eb-bd6a-00505683cc8f]
]
at org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.flushDbOperationException(EnginePersistenceLogger.java:131)
… 19 more
Caused by: org.apache.ibatis.exceptions.PersistenceException:

Error flushing statements. Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.insertExecution (batch index #5) failed. 4 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: ORA-00001: unique constraint (SIWORKFLOW.ACT_UNIQ_RU_BUS_KEY) violated

Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.insertExecution (batch index #5) failed. 4 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: ORA-00001: unique constraint (SIWORKFLOW.ACT_UNIQ_RU_BUS_KEY) violated

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.flushStatements(DefaultSqlSession.java:254)
at org.camunda.bpm.engine.impl.db.sql.DbSqlSession.flushBatchOperations(DbSqlSession.java:411)
at org.camunda.bpm.engine.impl.db.sql.BatchDbSqlSession.executeDbOperations(BatchDbSqlSession.java:74)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperations(DbEntityManager.java:341)
... 18 more

Caused by: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.insertExecution (batch index #5) failed. 4 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: ORA-00001: unique constraint (SIWORKFLOW.ACT_UNIQ_RU_BUS_KEY) violated

at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:149)
at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:129)
at org.apache.ibatis.executor.BaseExecutor.flushStatements(BaseExecutor.java:122)
at org.apache.ibatis.executor.CachingExecutor.flushStatements(CachingExecutor.java:114)
at org.apache.ibatis.session.defaults.DefaultSqlSession.flushStatements(DefaultSqlSession.java:252)
... 21 more

Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (SIWORKFLOW.ACT_UNIQ_RU_BUS_KEY) violated

at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:12296)
at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:246)
at com.zaxxer.hikari.pool.ProxyStatement.executeBatch(ProxyStatement.java:128)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeBatch(HikariProxyPreparedStatement.java)
at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:123)
... 25 more

@Sakar_Chugh. L1 Approval task and L2 manager approval task are not connected from source reference.

Except start and end events, every activity in the BPMN must connect from source and target activities/gateways/events.

Also check your db whether business key column has unique key constraints enabled.

@aravindhrs As I mentioned, I do have the unique key constraints enabled. Even after fixing the diagram the problem still exists. I want to understand why the constraint might be causing issues and if there is a workaround without removing the constraint itself.

Hi @Sakar_Chugh,

if you have the unique constraint, then you have to use a different business key for the second workflow…

Hope this helps, Ingo