1) Duplicate variables (duplicate name_, type_, execution_id_ and proc_inst_id_) are allowed to be created in the ACT_RU_VARIABLES table.
They have different "REV_" column values though.
2) At the end of the process when it goes to delete from the ACT_RU_EXECUTION table, there is a foreign key error (see stacktrace below).
When I keep the rest of the code the same and the only change I make is to use different variables names, I don't see any issues.
Also, looking at the table structure, it looks like the foreign key constraints aren't in the latest Activiti tables.
The overall symptom I see is that it keeps retrying every 5 minutes, but the process never gets closed (due to the FK error, a new entry just keeps getting inserted into the jobs table).
mysql> select * from act_ru_execution;
+-----+------+---------------+---------------+------------+--------------------------+-------------+-------------------+----------------------+------------+----------------+-----------+-----------------+-------------------+-------------------+
| ID_ | REV_ | PROC_INST_ID_ | BUSINESS_KEY_ | PARENT_ID_ | PROC_DEF_ID_ | SUPER_EXEC_ | ACT_ID_ | ACT_INST_ID_ | IS_ACTIVE_ | IS_CONCURRENT_ | IS_SCOPE_ | IS_EVENT_SCOPE_ | SUSPENSION_STATE_ | CACHED_ENT_STATE_ |
+-----+------+---------------+---------------+------------+--------------------------+-------------+-------------------+----------------------+------------+----------------+-----------+-----------------+-------------------+-------------------+
| 30 | 2 | 30 | NULL | NULL | cam_par_variables_1:1:27 | NULL | ParallelGateway_1 | 30 | 0 | 0 | 1 | 0 | 1 | 0 |
| 33 | 4 | 30 | NULL | 30 | cam_par_variables_1:1:27 | NULL | ParallelGateway_2 | ParallelGateway_2:47 | 0 | 1 | 0 | 0 | 1 | 11 |
| 34 | 2 | 30 | NULL | 30 | cam_par_variables_1:1:27 | NULL | ServiceTask_4 | NULL | 1 | 1 | 0 | 0 | 1 | 15 |
+-----+------+---------------+---------------+------------+--------------------------+-------------+-------------------+----------------------+------------+----------------+-----------+-----------------+-------------------+-------------------+
3 rows in set (0.00 sec)
Nov 26, 2013 4:48:22 PM org.camunda.bpm.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 delete or update a parent row: a foreign key constraint fails (`camunda`.`act_ru_variable`, CONSTRAINT `ACT_FK_VAR_EXE` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`))
### The error may involve org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity.deleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ? and REV_ = ?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`camunda`.`act_ru_variable`, CONSTRAINT `ACT_FK_VAR_EXE` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`))
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147)
at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:158)
at org.camunda.bpm.engine.impl.db.DbSqlSession$DeletePersistentObjectOperation.execute(DbSqlSession.java:264)
at org.camunda.bpm.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:735)
at org.camunda.bpm.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:502)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:211)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:154)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:32)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.executeJob(ExecuteJobsRunnable.java:79)
at org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJobsRunnable.java:67)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`camunda`.`act_ru_variable`, CONSTRAINT `ACT_FK_VAR_EXE` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`))
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1041)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2818)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2157)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1379)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)
... 16 more