cancel
Showing results for 
Search instead for 
Did you mean: 

Problem ending subprocess with active intermediate timer alive

kenrobrt
Champ in-the-making
Champ in-the-making
Hi,

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: https://www.dropbox.com/s/5d2bz670ob50i2c/img1.png?dl=0

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:
https://www.dropbox.com/s/xy0104lgxc9nx7n/img2.png?dl=0

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
org.apache.ibatis.exceptions.PersistenceException:
### 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(ExceptionFactory.java:26)[265:org.mybatis.mybatis:3.2.8]
        at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:154)[265:org.mybatis.mybatis:3.2.8]
        at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:165)[265:org.mybatis.mybatis:3.2.8]
        at org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation.execute(DbSqlSession.java:293)[259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.db.DbSqlSession.flushRegularDeletes(DbSqlSession.java:922)[259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:888)[259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:613)[259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:212)[259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:138)[259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66)[259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.interceptor.JtaTransactionInterceptor.execute(JtaTransactionInterceptor.java:65)[259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)[259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)[259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)[259:org.activiti.engine:5.19.0]
        at org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:69)[259:org.activiti.engine:5.19.0]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_21]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_21]
        at java.lang.Thread.run(Thread.java:722)[: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.
2 REPLIES 2

kenrobrt
Champ in-the-making
Champ in-the-making
Just noticed that the diagram is kind of confusing since inside "Waiting and reminding"-subprocess there's timer for sending email to signer again. That's old design so I removed it:
https://www.dropbox.com/s/0cn2kgqh9xemea6/img3.PNG?dl=0

kenrobrt
Champ in-the-making
Champ in-the-making
Looked more into it and that stack trace is related to another timer catch event in the diagram (the one right after when you exit Multi instance-subprocess). I then tried to delete it, made a new signing process and got stack trace again, now regarding yet another timer catch event inside Multi instance-subprocess. This worked fine before that reminder email-part and its timers.

EDIT: Alright, now it seems to work! Here's how I did it:
https://www.dropbox.com/s/1sqepb02f7a5rxe/img4.PNG?dl=0

So when everyone has signed and we exit multi instance subprocess, I signal the "Wait for 'everyone has signed' notification"-receive task so that the branching execution there reaches end state and is finished.