The execution of many processes at once will cause constraint violations with the ID_ field.

Description

We are seeing the following error in our logs:

SEVERE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:

  1.  

    1.  

      1. Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`activiti`.`ACT_RU_VARIABLE`, CONSTRAINT `ACT_FK_VAR_EXE` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`))

      2. The error may involve org.activiti.engine.impl.persistence.entity.VariableInstanceEntity.insertVariableInstance-Inline

      3. The error occurred while setting parameters

      4. SQL: insert into ACT_RU_VARIABLE (ID_, REV_, TYPE_, NAME_, PROC_INST_ID_, EXECUTION_ID_, TASK_ID_, BYTEARRAY_ID_, DOUBLE_, LONG_ , TEXT_, TEXT2_) values ( ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )

      5. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`activiti`.`ACT_RU_VARIABLE`, CONSTRAINT `ACT_FK_VAR_EXE` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`))

I believe the problem is probably with the way ID_ are being generated. In scenarios where you can have many activiti processes running at the same time the ID_ that is being generated for use can be duplicated, at least that is what I am seeing. A possible fix for this would be to use a UUID rather then an incremented counter.

Environment

None

Assignee

Joram Barrez

Reporter

Robert McKinnon

Labels

None

Fix versions

Affects versions

Priority

Critical
Configure