AnsweredAssumed Answered

Thread hangs during RuntimeService.startProcessInstanceByKey

Question asked by michalg on Jan 13, 2014
Latest reply on Sep 28, 2015 by elkammar
Hello,

I would like ask about a problem with Activiti, which starts to be quite serious. But first some background:
we are using Activiti as embedded Spring bean in our application. Application is deployed on several tomcat nodes.
Engine itself has standard configuration, only jobExecutor lock has been decreased:

  <bean id="configuredJobExecutor" class="org.activiti.engine.impl.jobexecutor.DefaultJobExecutor">
    <property name="lockTimeInMillis" value="120000"/> <!– 2 minutes –>
  </bean>

  <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
    <!– Database configurations –>
    <property name="databaseSchemaUpdate" value="true" />
    <property name="dataSource" ref="activitiDataSource" />
    <property name="transactionManager" ref="activitiTransactionManager" />
    <property name="jobExecutor" ref="configuredJobExecutor" />
    <property name="jobExecutorActivate" value="true" />
    <property name="deploymentResources" value="classpath*:/bpmn20/*.bpmn20.xml" />
  </bean>

  <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  </bean>
 
  <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
  <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
  <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
  <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
  <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />

We first started with Activiti version 5.9, but later upgraded to version 5.13 and lately to 5.14.
With 5.13 we observed problem with process instances not being started by runtime service (5.14 release contains lots of bug fixes, but unfortunately it didn't fix this one). When calling:
[java]
runtimeService.startProcessInstanceByKey(…)
[/java]
thread hangs - function does not return, no exception is thrown. To fix this we need to restart the application, which restarts the Activiti engine. After restart it works fine, but after random ammount of time (sometimes after 5 to 7 days, other times after 15 hours) problem occurs again and another restart is needed.

I've enabled debug logs on Activiti but they provide very little information for me. When problems occurs logs look like this:

DEBUG o.a.e.i.interceptor.LogInterceptor - — starting StartProcessInstanceCmd ——————————————————–
DEBUG o.a.e.i.p.e.P.selectLatestProcessDefinitionByKey - ooo Using Connection [Transaction-aware proxy for target Connection  from DataSource
DEBUG o.a.e.i.p.e.P.selectLatestProcessDefinitionByKey - ==>  Preparing: select * from ACT_RE_PROCDEF where KEY_ = ? and VERSION_ = (select max(VERSION_)
DEBUG o.a.e.i.p.e.P.selectLatestProcessDefinitionByKey - ==> Parameters: default_terminate(String), default_terminate(String)
DEBUG o.a.e.i.interceptor.LogInterceptor -                                                                                                    
DEBUG o.a.e.i.interceptor.LogInterceptor - — starting StartProcessInstanceCmd ——————————————————–
DEBUG o.a.e.i.p.e.P.selectLatestProcessDefinitionByKey - ooo Using Connection [Transaction-aware proxy for target Connection  from DataSource
DEBUG o.a.e.i.p.e.P.selectLatestProcessDefinitionByKey - ==>  Preparing: select * from ACT_RE_PROCDEF where KEY_ = ? and VERSION_ = (select max(VERSION_)
DEBUG o.a.e.i.p.e.P.selectLatestProcessDefinitionByKey - ==> Parameters: default_activate(String), default_activate(String)
DEBUG o.a.e.i.interceptor.LogInterceptor -

and after a while, it just logs:

[http-bio-8080-exec-2257] DEBUG o.a.e.i.interceptor.LogInterceptor -                                                                                              
[http-bio-8080-exec-2257] DEBUG o.a.e.i.interceptor.LogInterceptor - — starting StartProcessInstanceCmd ——————————————————–
[http-bio-8080-exec-2256] DEBUG o.a.e.i.interceptor.LogInterceptor -                                                                                              
[http-bio-8080-exec-2256] DEBUG o.a.e.i.interceptor.LogInterceptor - — starting StartProcessInstanceCmd ——————————————————–
[http-bio-8080-exec-2261] DEBUG o.a.e.i.interceptor.LogInterceptor -                                                                                              
[http-bio-8080-exec-2261] DEBUG o.a.e.i.interceptor.LogInterceptor - — starting StartProcessInstanceCmd ——————————————————–
[http-bio-8080-exec-2266] DEBUG o.a.e.i.interceptor.LogInterceptor - 

This problem is really annoying - at the moment we are forced to monitor application and restart the server every couple of days. There is no error thrown when this happens, thread just hangs when executing Activiti code.

Did anyone else had the same problem?
If needed I can provide more Activiti logs and information.

Thank you for any help

Outcomes