Hi
After I upgraded from 6.3.0 to 6.4.0 I get an exception when calling TaskService.completeTaskWithForm.
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table “act_ru_execution” violates foreign key constraint “act_fk_idl_procinst” on table “act_ru_identitylink”
Detail: Key (id_)=(cb33cd3e-1682-11e9-bd99-c67a55d1f07b) is still referenced from table “act_ru_identitylink”.
The database has the following:
flowable=> select id_, proc_inst_id_, start_user_id_, tenant_id_ from act_ru_execution where proc_inst_id_ = 'cb33cd3e-1682-11e9-bd99-c67a55d1f07b';
id_ | proc_inst_id_ | start_user_id_ | tenant_id_
--------------------------------------+--------------------------------------+----------------+------------
cb33cd41-1682-11e9-bd99-c67a55d1f07b | cb33cd3e-1682-11e9-bd99-c67a55d1f07b | | demo
cb33cd3e-1682-11e9-bd99-c67a55d1f07b | cb33cd3e-1682-11e9-bd99-c67a55d1f07b | admin | demo
(2 rows)
Looking at ExecutionEntityManagerImpl.deleteRelatedDataForExecution which then calls deleteIdentityLinks I see that for the second record above to which the identities are linked indeed goes through the process of adding a bulk delete.
In MybatisIdentityLinkDataManager.bulkDelete adds a delete bulk statement, and then it ends up calling deleteCachedEntities where there are 3 identity link entities with the same username. Two with type as ‘participant’ and a third with the type as ‘starter’, two of them are in the database and one ‘participant’ is not.
They go through this code:
With all three going through entityMatches and the one that is not in the database also passes the isInserted check.
In the logs the statement execution looks like this:
DEBUG org.flowable.task.service.impl.persistence.entity.TaskEntityImpl.deleteTask - ==> Preparing: delete from ACT_RU_TASK where ID_ = ? and REV_ = ?
DEBUG org.flowable.task.service.impl.persistence.entity.TaskEntityImpl.deleteTask - ==> Parameters: cb33f454-1682-11e9-bd99-c67a55d1f07b(String), 1(Integer)
DEBUG org.flowable.task.service.impl.persistence.entity.TaskEntityImpl.deleteTask - <== Updates: 1
DEBUG org.flowable.task.service.impl.persistence.entity.TaskEntityImpl.deleteTasksByExecutionId - ==> Preparing: delete from ACT_RU_TASK where EXECUTION_ID_ = ?
DEBUG org.flowable.task.service.impl.persistence.entity.TaskEntityImpl.deleteTasksByExecutionId - ==> Parameters: cb33cd3e-1682-11e9-bd99-c67a55d1f07b(String)
DEBUG org.flowable.task.service.impl.persistence.entity.TaskEntityImpl.deleteTasksByExecutionId - <== Updates: 0
DEBUG org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl.deleteExecution - ==> Preparing: delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ?
DEBUG org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl.deleteExecution - ==> Parameters: cb33cd41-1682-11e9-bd99-c67a55d1f07b(String), 2(Integer)
DEBUG org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl.deleteExecution - <== Updates: 1
DEBUG org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl.deleteExecution - ==> Preparing: delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ?
DEBUG org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl.deleteExecution - ==> Parameters: cb33cd3e-1682-11e9-bd99-c67a55d1f07b(String), 2(Integer)
And then the failure is on the last one, due to the identity links not being deleted.
Any ideas where to look next?