Hi,
I have the following process definitions:
<bpmn:signal id="stop" name="stop ${execution.getProcessInstanceId()}" />
<bpmn:process id="TestFrameProcess" name="Test Frame Process" isExecutable="true">
<bpmn:startEvent id="Start" name="Start" camunda:asyncBefore="true" />
<bpmn:callActivity id="TestMainProcess" name="TestMainProcess" calledElement="TestMainProcess" />
<bpmn:boundaryEvent id="Stopped" attachedToRef="TestMainProcess" cancelActivity="true" camunda:asyncAfter="true">
<bpmn:signalEventDefinition signalRef="stop" />
</bpmn:boundaryEvent>
<bpmn:sequenceFlow id="FromStoppedToEnd" name=""
sourceRef="Stopped"
targetRef="End" />
<bpmn:endEvent id="End" name="End" camunda:asyncBefore="true" />
<bpmn:sequenceFlow id="ToTestMainProcess" name=""
sourceRef="Start"
targetRef="TestMainProcess" />
<bpmn:sequenceFlow id="ToEnd" name=""
sourceRef="TestMainProcess"
targetRef="End" />
</bpmn:process>
and
<bpmn:process id="TestMainProcess" name="Test Main Process" isExecutable="true">
<bpmn:startEvent id="Start" name="Start" camunda:asyncBefore="true" />
<bpmn:serviceTask id="StopMeLater" name="StopMeLater" camunda:class="gps.workflow.test.StopMeLaterServiceTask" />
<bpmn:intermediateCatchEvent id="Timeout" name="Timeout">
<bpmn:timerEventDefinition>
<bpmn:timeDuration>PT1H</bpmn:timeDuration>
</bpmn:timerEventDefinition>
</bpmn:intermediateCatchEvent>
<bpmn:endEvent id="End" name="End" />
<bpmn:sequenceFlow id="ToStopMeLater" name=""
sourceRef="Start"
targetRef="StopMeLater" />
<bpmn:sequenceFlow id="ToTimeout" name=""
sourceRef="StopMeLater"
targetRef="Timeout" />
<bpmn:sequenceFlow id="ToEnd" name=""
sourceRef="Timeout"
targetRef="End" />
</bpmn:process>
This is the StopMeLater java delegate:
public class StopMeLaterServiceTask implements JavaDelegate {
@Override public void execute(DelegateExecution execution) throws Exception { new Thread(() -> { try { Thread.sleep((int)Math.floor(Math.random() * 10) * 100); CamundaProcess.executeProcessEngineOperation(processEngine -> { String superProcInstId = processEngine.getRuntimeService().createProcessInstanceQuery().subProcessInstanceId(execution.getProcessInstanceId()).singleResult().getId(); processEngine.getRuntimeService().signalEventReceived("stop " + superProcInstId); System.out.println("process " + execution.getProcessInstanceId() + " stopped."); }); } catch (InterruptedException e) { e.printStackTrace(); } }).start(); }
}
It starts a new thread that waits a short time and then sends the stop signal to the frame process.
If I call start the frame process often enough (like 100 or 1000 times), sometimes this exception is thrown:
[Thread-94] ERROR org.camunda.bpm.engine.context - ENGINE-16004 Exception while closing command context: ENGINE-03004 Exception while executing Database Operation ‘DELETE ExecutionEntity[24662878]’ with message ’
Error flushing statements. Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution (batch index #5) failed. 4 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: Batch entry 1 delete from ACT_RU_EXECUTION where ID_ = ‘24662868’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_super” on table “act_ru_execution”
Detail: Key (id_)=(24662868) 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 #5) failed. 4 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: Batch entry 1 delete from ACT_RU_EXECUTION where ID_ = ‘24662868’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_super” on table “act_ru_execution”
Detail: Key (id_)=(24662868) is still referenced from table “act_ru_execution”. Call getNextException to see other errors in the batch.'. Flush summary:
[
INSERT HistoricActivityInstanceEventEntity[Stopped:24662939]
INSERT MessageEntity[24662941]
DELETE EventSubscriptionEntity[24662869]
UPDATE ExecutionEntity[24662756]
DELETE ExecutionEntity[24662878]
DELETE ExecutionEntity[24662868]
UPDATE HistoricActivityInstanceEventEntity[TestMainProcess:24662870]
UPDATE HistoricProcessInstanceEventEntity[24662878]
]
org.camunda.bpm.engine.ProcessEngineException: ENGINE-03004 Exception while executing Database Operation ‘DELETE ExecutionEntity[24662878]’ with message ’Error flushing statements. Cause: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution (batch index #5) failed. 4 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: Batch entry 1 delete from ACT_RU_EXECUTION where ID_ = ‘24662868’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_super” on table “act_ru_execution”
Detail: Key (id_)=(24662868) 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 #5) failed. 4 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: Batch entry 1 delete from ACT_RU_EXECUTION where ID_ = ‘24662868’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_super” on table “act_ru_execution”
Detail: Key (id_)=(24662868) is still referenced from table “act_ru_execution”. Call getNextException to see other errors in the batch.'. Flush summary:
[
INSERT HistoricActivityInstanceEventEntity[Stopped:24662939]
INSERT MessageEntity[24662941]
DELETE EventSubscriptionEntity[24662869]
UPDATE ExecutionEntity[24662756]
DELETE ExecutionEntity[24662878]
DELETE ExecutionEntity[24662868]
UPDATE HistoricActivityInstanceEventEntity[TestMainProcess:24662870]
UPDATE HistoricProcessInstanceEventEntity[24662878]
]
at org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.flushDbOperationException(EnginePersistenceLogger.java:131)
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:322)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flush(DbEntityManager.java:294)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:263)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:186)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:119)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:70)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
at org.camunda.bpm.engine.impl.SignalEventReceivedBuilderImpl.send(SignalEventReceivedBuilderImpl.java:94)
at org.camunda.bpm.engine.impl.RuntimeServiceImpl.signalEventReceived(RuntimeServiceImpl.java:591)
at gps.workflow.test.StopMeLaterServiceTask.lambda$execute$0(StopMeLaterServiceTask.java:20)
at gps.workflow.process.CamundaProcess.executeProcessEngineOperation(CamundaProcess.java:131)
at gps.workflow.test.StopMeLaterServiceTask.lambda$execute$1(StopMeLaterServiceTask.java:18)
at java.base/java.lang.Thread.run(Thread.java:834)
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 #5) failed. 4 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: Batch entry 1 delete from ACT_RU_EXECUTION where ID_ = ‘24662868’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_super” on table “act_ru_execution”
Detail: Key (id_)=(24662868) 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 #5) failed. 4 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: Batch entry 1 delete from ACT_RU_EXECUTION where ID_ = ‘24662868’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_super” on table “act_ru_execution”
Detail: Key (id_)=(24662868) 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:320)
at org.camunda.bpm.engine.impl.db.sql.BatchDbSqlSession.executeDbOperations(BatchDbSqlSession.java:68)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperations(DbEntityManager.java:339)
… 13 more
Caused by: org.apache.ibatis.executor.BatchExecutorException: org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution (batch index #5) failed. 4 prior sub executor(s) completed successfully, but will be rolled back. Cause: java.sql.BatchUpdateException: Batch entry 1 delete from ACT_RU_EXECUTION where ID_ = ‘24662868’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_super” on table “act_ru_execution”
Detail: Key (id_)=(24662868) 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)
at org.apache.ibatis.executor.CachingExecutor.flushStatements(CachingExecutor.java:114)
at org.apache.ibatis.session.defaults.DefaultSqlSession.flushStatements(DefaultSqlSession.java:252)
… 16 more
Caused by: java.sql.BatchUpdateException: Batch entry 1 delete from ACT_RU_EXECUTION where ID_ = ‘24662868’ and REV_ = 1 was aborted: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_super” on table “act_ru_execution”
Detail: Key (id_)=(24662868) 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:148)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2184)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:481)
at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:840)
at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1538)
at org.apache.ibatis.executor.BatchExecutor.doFlushStatements(BatchExecutor.java:123)
… 20 more
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_exe_super” on table “act_ru_execution”
Detail: Key (id_)=(24662868) is still referenced from table “act_ru_execution”.
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2440)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2183)
… 24 more
Is there anything I can do to prevent this? I’m using Camunda version 7.13.0.
Thank you in advance for your help!