cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel Gateway: Two Instances of UserTask are created mistakenly

wl21st
Champ in-the-making
Champ in-the-making
Hi All,

Attached the process definition.  I am working on a process POC which uses a parallel gateway/exclusive gateway, inclusive gateway, service tasks/user tasks and timerevent.  Strangely enough the two same user task(user task1) are created.  From debug, it seems that the Timer1 event has locking failure and and retried after 1 min.  Stacktrace in the job failure stacktrace.
<blockcode>
org.activiti.engine.ActivitiOptimisticLockingException: JobEntity [id=7617] was updated by another transaction concurrently
   at org.activiti.engine.impl.db.DbSqlSession$CheckedDeleteOperation.execute(DbSqlSession.java:286)
   at org.activiti.engine.impl.db.DbSqlSession.flushRegularDeletes(DbSqlSession.java:834)
   at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:798)
   at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:595)
   at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:211)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:137)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:66)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:37)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
   at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
   at org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:73)
</blockcode>

The two instances of the UserTask_1 are the result of two executions of the Timer1.  And at the second time, there is following stacktrace.
<blockcode>
java.lang.NullPointerException: while trying to invoke the method org.activiti.engine.impl.pvm.process.ActivityImpl.isScope() of a null object loaded from local variable 'activity'
     at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:35)
     at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
     at org.activiti.engine.impl.jobexecutor.AsyncContinuationJobHandler.execute(AsyncContinuationJobHandler.java:35)
     at org.activiti.engine.impl.persistence.entity.JobEntity.execute(JobEntity.java:84)
     at org.activiti.engine.impl.persistence.entity.MessageEntity.execute(MessageEntity.java:29)
     at org.activiti.engine.impl.cmd.ExecuteAsyncJobCmd.execute(ExecuteAsyncJobCmd.java:52)
     at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
     at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
     at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:37)
     at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
     at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
     at org.activiti.engine.impl.asyncexecutor.ExecuteAsyncRunnable.run(ExecuteAsyncRunnable.java:73)
</blockcode>

When I tried to complete the two userTask1 instances, I got the exceptions and unable to complete any of them.

Using:
  1. Activiti 5.17.0 Async Job Executor and JBoss EAP 4.3 with JTA enabled environment.

Possible directions next steps:
    1. I am using StandaloneProcessEngineConfiguration(not JtaProcessEngineConfiguration).  Can this be related to the retry of jobs?
    2. Will the use async job executor related?  Will it be good chance to switch to non-async work?
    3. Process definition issue? 
    4. Issue in the engine side?
    5. others?

I have been working on this issue for a while and didn't get much progress of the root cause.  Any information will be very helpful and appreciated!

Sincerely yours,
Michael Luo
4 REPLIES 4

trademak
Star Contributor
Star Contributor
Hi Michael,

1. Don't think so, it just means that no JTA is used in Activiti
2. I don't think so, but you could give it a try of course.

Would it be possible to create a unit test showing the issue? That would make it a lot easier to reproduce the issue for us.

Best regards,

wl21st
Champ in-the-making
Champ in-the-making
Thanks Tijs for your quick reply.  Will follow up on this and update accordingly.

Sincerely yours,
Michael Luo

wl21st
Champ in-the-making
Champ in-the-making
Actually the root cause of the issue is
1. I am using StandaloneProcessEngineConfiguration(not JtaProcessEngineConfiguration). Can this be related to the retry of jobs?
After I switched to the Jta and TransactionManager, the issue is resolved.

jbarrez
Star Contributor
Star Contributor
Ah yes. Good catch. The way transactions are treated is completely different in those two.