Referential integrity constraint violation while deleting the Deployment

Hi All,

After suspending the process definition, when I try to delete the deployment I get following error
Code :

repositoryService
.createDeploymentQuery()
.processDefinitionKey(processDef)
.list().forEach(deployment → {
runtimeService.createProcessInstanceQuery()
.deploymentId(deployment.getId()).active().list()
.forEach(process → {
runtimeService.deleteProcessInstance(process.getId(), “Deployment delete”);
});

repositoryService.deleteDeployment(deployment.getId(), true);

Error :

  • Error updating database. Cause: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: “ACT_FK_DEADLETTER_JOB_PROC_DEF: PUBLIC.ACT_RU_DEADLETTER_JOB FOREIGN KEY(PROC_DEF_ID_) REFERENCES PUBLIC.ACT_RE_PROCDEF(ID_) (‘Modbus2RedisAWS:1:c4863f83-eab3-11eb-a4d0-0242ac120009’)”; SQL statement:
  • today at 11:01:03 PM delete from ACT_RE_PROCDEF where DEPLOYMENT_ID_ = ? [23503-185]
  • today at 11:01:03 PM ### The error may exist in org/flowable/db/mapping/entity/ProcessDefinition.xml
  • today at 11:01:03 PM ### The error may involve org.flowable.engine.impl.persistence.entity.ProcessDefinitionEntityImpl.deleteProcessDefinitionsByDeploymentId-Inline
  • today at 11:01:03 PM ### The error occurred while setting parameters
  • today at 11:01:03 PM ### SQL: delete from ACT_RE_PROCDEF where DEPLOYMENT_ID_ = ?

Can anyone help me to resolve this issue ?

Regards,
Pratik