Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: update or delete on table "act_ru_execution" violates foreign key constraint when using parallel and sub process flow

Hello, I have a problem when using parallel and sub process flow on camunda pipleline, so there is an edge case on production environment (can’t reproduce it on local environment) when camunda engine want’s to delete the executions it still referenced from table act_ru_execution, can anyone please help me with this, thanks :pray:

08:44:46 [http-nio-3008-exec-3] [ERROR] - org.camunda.bpm.engine.context
ENGINE-16004 Exception while closing command context: An exception occurred in the persistence layer. Please check the server logs for a detailed message and the entire exception stack trace. 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)
Caused by: org.camunda.bpm.engine.ProcessEngineException: ENGINE-03004 Exception while executing Database Operation ‘DELETE ExecutionEntity[befa73da-dfc8-11eb-9a93-46bab0497fac]’ 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: Batch entry 6 delete from ACT_RU_EXECUTION where ID_ = ‘befa4cc3-dfc8-11eb-9a93-46bab0497fac’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_parent” on table “act_ru_execution”

Detail: Key (id_)=(befa4cc3-dfc8-11eb-9a93-46bab0497fac) is still referenced from table “act_ru_execution”. Call getNextException to see other errors in the batch.

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: Batch entry 6 delete from ACT_RU_EXECUTION where ID_ = ‘befa4cc3-dfc8-11eb-9a93-46bab0497fac’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_parent” on table “act_ru_execution”

Detail: Key (id_)=(befa4cc3-dfc8-11eb-9a93-46bab0497fac) is still referenced from table “act_ru_execution”. Call getNextException to see other errors in the batch.
java.sql.BatchUpdateException: Batch entry 6 delete from ACT_RU_EXECUTION where ID_ = ‘befa4cc3-dfc8-11eb-9a93-46bab0497fac’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_parent” on table “act_ru_execution”
Detail: Key (id_)=(befa4cc3-dfc8-11eb-9a93-46bab0497fac) is still referenced from table “act_ru_execution”. Call getNextException to see other errors in the batch.
org.postgresql.util.PSQLException: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_parent” on table “act_ru_execution”
Detail: Key (id_)=(befa4cc3-dfc8-11eb-9a93-46bab0497fac) is still referenced from table “act_ru_execution”.
org.postgresql.util.PSQLException: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_parent” on table “act_ru_execution”
Detail: Key (id_)=(befa4cc3-dfc8-11eb-9a93-46bab0497fac) is still referenced from table “act_ru_execution”.
'. Flush summary:
[
INSERT VariableInstanceEntity[bfb6bf64-dfc8-11eb-a3c0-8af559fd1906]
DELETE ExternalTaskEntity[befa73df-dfc8-11eb-9a93-46bab0497fac]
DELETE ExternalTaskEntity[befa73e2-dfc8-11eb-9a93-46bab0497fac]
UPDATE ExecutionEntity[befa25ab-dfc8-11eb-9a93-46bab0497fac]
UPDATE ExecutionEntity[bef9fe96-dfc8-11eb-9a93-46bab0497fac]
3:44
DELETE ExecutionEntity[befa73da-dfc8-11eb-9a93-46bab0497fac]
DELETE ExecutionEntity[befa4cc7-dfc8-11eb-9a93-46bab0497fac]
DELETE ExecutionEntity[befa73dd-dfc8-11eb-9a93-46bab0497fac]
DELETE ExecutionEntity[befa4cc8-dfc8-11eb-9a93-46bab0497fac]
DELETE ExecutionEntity[befa73e0-dfc8-11eb-9a93-46bab0497fac]
DELETE ExecutionEntity[befa4cc9-dfc8-11eb-9a93-46bab0497fac]
DELETE ExecutionEntity[befa4cc3-dfc8-11eb-9a93-46bab0497fac]
]
at org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.flushDbOperationException(EnginePersistenceLogger.java:131)
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)
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: Batch entry 6 delete from ACT_RU_EXECUTION where ID_ = ‘befa4cc3-dfc8-11eb-9a93-46bab0497fac’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_parent” on table “act_ru_execution”

Detail: Key (id_)=(befa4cc3-dfc8-11eb-9a93-46bab0497fac) is still referenced from table “act_ru_execution”. Call getNextException to see other errors in the batch.

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: Batch entry 6 delete from ACT_RU_EXECUTION where ID_ = ‘befa4cc3-dfc8-11eb-9a93-46bab0497fac’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_parent” on table “act_ru_execution”

Detail: Key (id_)=(befa4cc3-dfc8-11eb-9a93-46bab0497fac) is still referenced from table “act_ru_execution”. Call getNextException to see other errors in the batch.
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)
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: Batch entry 6 delete from ACT_RU_EXECUTION where ID_ = ‘befa4cc3-dfc8-11eb-9a93-46bab0497fac’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_parent” on table “act_ru_execution”
Detail: Key (id_)=(befa4cc3-dfc8-11eb-9a93-46bab0497fac) is still referenced from table “act_ru_execution”. Call getNextException to see other errors in the batch.
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)
3:44
at org.apache.ibatis.executor.CachingExecutor.flushStatements(CachingExecutor.java:114)
at org.apache.ibatis.session.defaults.DefaultSqlSession.flushStatements(DefaultSqlSession.java:252)
Caused by: java.sql.BatchUpdateException: Batch entry 6 delete from ACT_RU_EXECUTION where ID_ = ‘befa4cc3-dfc8-11eb-9a93-46bab0497fac’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_parent” on table “act_ru_execution”
Detail: Key (id_)=(befa4cc3-dfc8-11eb-9a93-46bab0497fac) is still referenced from table “act_ru_execution”. Call getNextException to see other errors in the batch.
at org.postgresql.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:169)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2286)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:521)
at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:878)
at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:901)
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_parent” on table “act_ru_execution”
Detail: Key (id_)=(befa4cc3-dfc8-11eb-9a93-46bab0497fac) is still referenced from table “act_ru_execution”.
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:521)
at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:878)
at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:901)

Below is my bpmn tree diagram

Can you take a look at the Style Guide? It’ll help you understand how to format code correctly and also help you create questions that are easy to understand and also easier to answer :slight_smile:

oo yeah sure, thanks :pray:

Can you also upload you model?
And give more details about what you Camunda setup is?

Sorry for late response, I found out the issue is happen because I’m using the subprocess and terminate end event on it, so when the subprocess is done the camunda engine will try to delete the subprocess act_ru_execution row, but it still referenced to the main process because it’s not done yet.

anyway my camunda setup is using springboot applications, thanks for your response @Niall :pray:

1 Like

I have the same problem. How did you solve your situation?

I solve it by using end event instead of terminate end event

end event
Screenshot 2023-05-31 at 21.31.30

terminate end event
Screenshot 2023-05-31 at 21.31.50

A generic end event terminate only the process flows they are attached to. A terminate end event terminates the entire process, including any sub-processes and process flows, even if these do not end in terminate end events.

2 Likes