AnsweredAssumed Answered

Problem ending subprocess with active intermediate timer alive

Question asked by kenrobrt on Jun 27, 2016
Latest reply on Jun 28, 2016 by kenrobrt

we are making electronic signing software which works like this: we create a form that needs to be signed by one or multiple signers. This initiates a signing process where we use Activiti. In our BPMN diagram we loop a list of persons which are sent email that they need to sign the form in a website. This is done as a multi-instance subprocess. We create a receive task for every signer and then wait that each of them has signed before we move on to archive the form.

We are now implementing logic where we send reminder email for signers who haven't signed after a certain period. Here's image of our BPMN diagram, I have marked the spot where I implemented the reminder email logic:

So I attached a timer boundary event to that subprocess, I also set cancelActivity=false for it. It works as intended except.. the problem is now that when everyone has signed and we exit "Multi instance: signing"-subprocess and then reach end state in "Parallel signing process"-subprocess, Activiti goes nuts because that intermediate timer event (the one just before reminder email-task) is still alive:

At least I think that's why I always get the following stack trace in logs if the timer boundary event has time to trigger before everyone has signed:

SGN | ERROR | 2016-06-27 10:37:39,506 | pool-13-thread-1 | ExecuteAsyncRunnable             | 259 - org.activiti.engine - 5.19.0 | Job 42585 failed
### Error updating database.  Cause: java.sql.SQLException: The DELETE statement conflicted with the SAME TABLE REFERENCE constraint "ACT_FK_EXE_PARENT". The conflict occurred in database "opsa-dev5_act", table "dbo.ACT_RU_EXECUTION", column 'PARENT_ID_'.
### 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: java.sql.SQLException: The DELETE statement conflicted with the SAME TABLE REFERENCE constraint "ACT_FK_EXE_PARENT". The conflict occurred in database "opsa-dev5_act", table "dbo.ACT_RU_EXECUTION", column 'PARENT_ID_'.
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException([265:org.mybatis.mybatis:3.2.8]
        at org.apache.ibatis.session.defaults.DefaultSqlSession.update([265:org.mybatis.mybatis:3.2.8]
        at org.apache.ibatis.session.defaults.DefaultSqlSession.delete([265:org.mybatis.mybatis:3.2.8]
        at org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation.execute([259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.db.DbSqlSession.flushRegularDeletes([259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.db.DbSqlSession.flushDeletes([259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.db.DbSqlSession.flush([259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.interceptor.CommandContext.flushSessions([259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.interceptor.CommandContext.close([259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute([259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.interceptor.JtaTransactionInterceptor.execute([259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.interceptor.LogInterceptor.execute([259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute([259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute([259:org.activiti.engine:5.19.0]
        at java.util.concurrent.ThreadPoolExecutor.runWorker([:1.7.0_21]
        at java.util.concurrent.ThreadPoolExecutor$[:1.7.0_21]

So what can I do? I already tried to programmatically delete the timer in ExecutionListener just before reaching end state in "Parallel signing process"-subprocess but I guess Activiti didn't allow it because the timer was active. Can I improve the design of my BPMN diagram? I'll add it as an attachment.