DELETE statement conflicted with the REFERENCE constraint "ACT_FK_VAR_EXE" exception on End Event

Hello,

we have a process that throws an exception every time the process instance ends on one of the end events. The exception is not thrown when the process ends with the other end event.

We’ve tried to set async before and after on the end event, but the only thing that prevented the exception from being thrown was adding a sleep to the task before the end event.

ENGINE-16004 Exception while closing command context: ENGINE-03083 Exception while executing Batch
Database Operations with message '### Error flushing statements.
Cause: org.apache.ibatis.executor.BatchExecutorException:
org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution (batch index #4) failed.
3 prior sub executor(s) completed successfully, but will be rolled back.
Cause: java.sql.BatchUpdateException: The DELETE statement conflicted with the REFERENCE constraint
“ACT_FK_VAR_EXE”. The conflict occurred in database “xxx”, table “dbo.ACT_RU_VARIABLE”, column
‘EXECUTION_ID_’. ###
Cause: org.apache.ibatis.executor.BatchExecutorException:
org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution (batch index #4) failed.
3 prior sub executor(s) completed successfully, but will be rolled back.
Cause: java.sql.BatchUpdateException: The DELETE statement conflicted with the REFERENCE constraint
“ACT_FK_VAR_EXE”. The conflict occurred in database “xxx”, table “dbo.ACT_RU_VARIABLE”, column
‘EXECUTION_ID_’.
java.sql.BatchUpdateException: The DELETE statement conflicted with the REFERENCE
constraint “ACT_FK_VAR_EXE”. The conflict occurred in database “xxx”, table “dbo.ACT_RU_VARIABLE”,
column ‘EXECUTION_ID_’.
'. Flush summary:
[
DELETE VariableInstanceEntity[3a5b8a19-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5b8a1b-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5b8a1d-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5b8a1f-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5b8a21-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5bb133-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5bb135-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5bb137-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3ab283ce-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3aca2a86-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3b5330b6-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3b5357c8-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3b858b5f-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3bb09306-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3bb0ba1b-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3cee9154-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3cef7bba-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3cef7bbf-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[53c28819-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[53c2881d-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[53c2881f-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[53c28821-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[53c28823-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[53c2af36-c805-11e9-b3b5-0242b3ff97cc]
DELETE ByteArrayEntity[3bb09305-c805-11e9-b3b5-0242b3ff97cc]
DELETE ByteArrayEntity[3bb0ba1a-c805-11e9-b3b5-0242b3ff97cc]
DELETE ByteArrayEntity[3cee9153-c805-11e9-b3b5-0242b3ff97cc]
DELETE ByteArrayEntity[3cef7bb9-c805-11e9-b3b5-0242b3ff97cc]
DELETE ByteArrayEntity[3cef7bbe-c805-11e9-b3b5-0242b3ff97cc]
DELETE ByteArrayEntity[5422f7b8-c805-11e9-b3b5-0242b3ff97cc]
UPDATE ExecutionEntity[38c9510a-c805-11e9-b3b5-0242b3ff97cc]
DELETE ExecutionEntity[3963e37a-c805-11e9-b3b5-0242b3ff97cc]
DELETE ExecutionEntity[395c9078-c805-11e9-b3b5-0242b3ff97cc]
UPDATE HistoricActivityInstanceEventEntity[xxx:395c9079-c805-11e9-b3b5-0242b3ff97cc]
UPDATE HistoricProcessInstanceEventEntity[3963e37a-c805-11e9-b3b5-0242b3ff97cc]
UPDATE HistoricVariableInstanceEntity[38ca3b76-c805-11e9-b3b5-0242b3ff97cc]
] > [camundaTaskExecutor-13] org.camunda.bpm.engine.context
org.camunda.bpm.engine.ProcessEngineException: ENGINE-03083 Exception while executing Batch Database Operations with message ’ ###
Error flushing statements. Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution (batch index #4) failed. 3 prior sub execu
tor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: The DELETE statement conflicted with the REFERENCE constraint “ACT_FK_VAR_EXE”. The conflict occurred in database “xxx”, table “dbo.ACT_RU_VARIABLE”, column ‘EXECUTION_ID_’. ###
Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution (batch index #4) failed. 3 prior sub executor(s) completed successfully,
but will be rolled back. Cause: java.sql.BatchUpdateException: The DELETE statement conflicted with the REFERENCE constraint “ACT_FK_VAR_EXE”. The conflict occurred in database “xxx”, table “dbo.ACT_RU_VARIABLE”, column ‘EXECUTION_ID_’.
java.sql.BatchUpdateException: The DELETE statement conflicted with the REFERENCE constraint “ACT_FK_VAR_EXE”. The conflict occurred in database “xxx”, table “dbo.ACT_RU_VARIABLE”, column ‘EXECUTION_ID_’.
'. Flush summary:
[
DELETE VariableInstanceEntity[3a5b8a19-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5b8a1b-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5b8a1d-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5b8a1f-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5b8a21-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5bb133-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5bb135-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3a5bb137-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3ab283ce-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3aca2a86-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3b5330b6-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3b5357c8-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3b858b5f-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3bb09306-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3bb0ba1b-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3cee9154-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3cef7bba-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[3cef7bbf-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[53c28819-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[53c2881d-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[53c2881f-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[53c28821-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[53c28823-c805-11e9-b3b5-0242b3ff97cc]
DELETE VariableInstanceEntity[53c2af36-c805-11e9-b3b5-0242b3ff97cc]
DELETE ByteArrayEntity[3bb09305-c805-11e9-b3b5-0242b3ff97cc]
DELETE ByteArrayEntity[3bb0ba1a-c805-11e9-b3b5-0242b3ff97cc]
DELETE ByteArrayEntity[3cee9153-c805-11e9-b3b5-0242b3ff97cc]
DELETE ByteArrayEntity[3cef7bb9-c805-11e9-b3b5-0242b3ff97cc]
DELETE ByteArrayEntity[3cef7bbe-c805-11e9-b3b5-0242b3ff97cc]
DELETE ByteArrayEntity[5422f7b8-c805-11e9-b3b5-0242b3ff97cc]
UPDATE ExecutionEntity[38c9510a-c805-11e9-b3b5-0242b3ff97cc]
DELETE ExecutionEntity[3963e37a-c805-11e9-b3b5-0242b3ff97cc]
DELETE ExecutionEntity[395c9078-c805-11e9-b3b5-0242b3ff97cc]
UPDATE HistoricActivityInstanceEventEntity[xxx:395c9079-c805-11e9-b3b5-0242b3ff97cc]
UPDATE HistoricProcessInstanceEventEntity[3963e37a-c805-11e9-b3b5-0242b3ff97cc]
UPDATE HistoricVariableInstanceEntity[38ca3b76-c805-11e9-b3b5-0242b3ff97cc]
]
at org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.flushDbOperationsException(EnginePersistenceLogger.java:698)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperations(DbEntityManager.java:355)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperationManager(DbEntityManager.java:318)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flush(DbEntityManager.java:290)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:203)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:132)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:113)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:36)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper.executeJob(ExecuteJobHelper.java:29)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.executeJob(ExecuteJobsRunnable.java:88)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:57)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.ibatis.exceptions.PersistenceException: ###
Error flushing statements. Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution (batch index #4) failed. 3 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: The DELETE statement conflicted with the REFERENCE constraint “ACT_FK_VAR_EXE”. The conflict occurred in database “xxx”, table “dbo.ACT_RU_VARIABLE”, column ‘EXECUTION_ID_’. ###
Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution (batch index #4) failed. 3 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: The DELETE statement conflicted with the REFERENCE constraint “ACT_FK_VAR_EXE”. The conflict occurred in database “xxx”, table “dbo.ACT_RU_VARIABLE”, column ‘EXECUTION_ID_’.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.flushStatements(DefaultSqlSession.java:255)
at org.camunda.bpm.engine.impl.db.sql.DbSqlSession.flushOperations(DbSqlSession.java:88)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperations(DbEntityManager.java:350)
… 17 common frames omitted
Caused by: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution (batch index #4) failed. 3 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: The DELETE statement conflicted with the REFERENCE constraint “ACT_FK_VAR_EXE”. The conflict occurred in database “xxx”, table “dbo.ACT_RU_VARIABLE”, column ‘EXECUTION_ID_’.
at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:146)
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:253)
… 19 common frames omitted
Caused by: java.sql.BatchUpdateException: The DELETE statement conflicted with the REFERENCE constraint “ACT_FK_VAR_EXE”. The conflict occurred in database “xxx”, table “dbo.ACT_RU_VARIABLE”, column ‘EXECUTION_ID_’.
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(SQLServerPreparedStatement.java:2303)
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:122)
… 23 common frames omitted

We get the exact same error, when we try to end a usertask within parallel subprocesses. It is not reproducable at the same spot, it just shows up after some time…

Can you give some details about your setup?
Camunda version?
database?
and upload the process if possible.