AnsweredAssumed Answered

Mac vs PC database-related anomaly

Question asked by bwd on Apr 20, 2011
Latest reply on Aug 27, 2011 by crkhd
We have developers running Activiti 5.4 on a mixture of Windows 7 and Mac boxes using MySQL 5.5 as the data store (each developer has a local database).

Things seem to work fine on Windows, but the Mac developers are reporting the following error when starting a workflow:

Apr 19, 2011 1:51:42 PM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`foo`.`act_ru_identitylink`, CONSTRAINT `ACT_FK_TSKASS_TASK` FOREIGN KEY (`TASK_ID_`) REFERENCES `ACT_RU_TASK` (`ID_`))
### The error may involve org.activiti.persistence.insertIdentityLink-Inline
### The error occurred while setting parameters
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`instance_2`.`act_ru_identitylink`, CONSTRAINT `ACT_FK_TSKASS_TASK` FOREIGN KEY (`TASK_ID_`) REFERENCES `ACT_RU_TASK` (`ID_`))
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:100)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:87)
        at org.activiti.engine.impl.db.DbSqlSession.flushInserts(DbSqlSession.java:392)
        at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:319)
        at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:134)
        at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:90)
        at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)
        at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
        at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
        at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
        at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
        at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceByKey(RuntimeServiceImpl.java:49)

When we look at the query logs, it appears to be associated with the following SQL:


118 Query     insert into ACT_RU_TASK (ID_, REV_, NAME_, DESCRIPTION_, PRIORITY_, CREATE_TIME_, OWNER_,
                      ASSIGNEE_, DELEGATION_, EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_KEY_, DUE_DATE_)
    values ('157',
            1,
            'foo',
            'bar',
            50,
            '2011-04-20 13:15:52',
            null,
            null,
            null,
            '146',
            '146',
            'sid-1e597cf9-9344-4dd7-922b-9b63534e2660:3:131',
            'sid-30C80E2F-EBA5-43E5-86ED-164CF88DC1E5',
            null
           )

and then a few queries later
                 
118 Query     insert into ACT_RU_IDENTITYLINK (ID_, REV_, TYPE_, USER_ID_, GROUP_ID_, TASK_ID_)
    values ('158',
            1,
            'candidate',
            '2:2',
            null,
            '157')
117 Query     rollback
117 Query     SET autocommit=1

One of the developers was able to get past this by dropping the foreign key constraint, but this later resulted in a similar error associated with another query.

FYI - We're running multiple Process Engines in a single servlet container, but each is given a distinct DataSource pointing to a different database schema.

One additional question came up during a review of the query logs:  Is Activiti modifying the connections it obtains from the DataSource connection pool?  (Someone noticed the 'SET autocommit' statements.)

Thanks,

BD

Outcomes