Activiti: Fork execution's end and async user task cause referential integrity constraint violation error.

Created on 16 Dec 2017  路  2Comments  路  Source: Activiti/Activiti

Overview

When Task1 is completed in the following process diagram, referential integrity constraint violation error occurs.

bug_process

### The error may involve org.activiti.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ?
### Cause: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "ACT_FK_TASK_EXE: PUBLIC.ACT_RU_TASK FOREIGN KEY(EXECUTION_ID_) REFERENCES PUBLIC.ACT_RU_EXECUTION(ID_) ('1656')"
Referential integrity constraint violation: "ACT_FK_TASK_EXE: PUBLIC.ACT_RU_TASK FOREIGN KEY(EXECUTION_ID_) REFERENCES PUBLIC.ACT_RU_EXECUTION(ID_) ('1656')"; SQL statement:
delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ? [23503-176]
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:172)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:185)
    at org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation.execute(DbSqlSession.java:293)
    at org.activiti.engine.impl.db.DbSqlSession.flushRegularDeletes(DbSqlSession.java:897)
    at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:890)
    at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:617)
    at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:212)
    at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:138)
    at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66)
    at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
    at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
    at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
    at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
    at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
    at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
    at org.activiti.engine.impl.TaskServiceImpl.complete(TaskServiceImpl.java:178)

Detail

  1. Make fork executions by using parallel gateway.
  2. Place an asynchronous user task in one of the executions.
  3. With the asynchronous user task stopped, complete the other execution.
  4. Referential integrity constraint violation error occurs.
  • Version to reproduce: Only 5.x

Cause

  • Premise

    • When forked by the parallel gateway, the forked executions is generated in addition to the execution of the process instance.

    • At the time when only one forked execution remains, the forked execution is replaced to the execution of the process instance. And, the forked execution that was left is deleted.

  • But, replacing executionId that should be executed at the completion of the forked execution is not applied to the asynchronous user task.
  • So, the record of the asynchronous user task still refer to the forked execution. Referential integrity constraint violation error occurs.

  • It is not the same cause, but related to the fix of the following pull request.
    https://github.com/Activiti/Activiti/pull/1612

bug

Most helpful comment

@daisuke-yoshimoto does the fix in #1612 fix this one as well?

All 2 comments

@daisuke-yoshimoto does the fix in #1612 fix this one as well?

@balsarori
I'm sorry for being confused.
No, this bug event will not be fixed by fixing the pull request.

However, it is a related bug.
Both bugs are related to replacing executionId in the timing that the forked execution is removed.

I'm still thinking about how to fix this bug.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zx445146042zx picture zx445146042zx  路  3Comments

salaboy picture salaboy  路  4Comments

leiyanfamily picture leiyanfamily  路  3Comments

xxf0925 picture xxf0925  路  9Comments

bikabdel picture bikabdel  路  4Comments