AnsweredAssumed Answered

Error in async process- Error while closing command context

Question asked by k_kunti@yahoo.com on Dec 1, 2012
Latest reply on Dec 11, 2012 by ronald.van.kuijk
Dear Activiti team

I am using activiti 5.10 with SQLserver DB. My process has 4 async service task where each task call a stored procedure that takes 1 min to execute. I am getting the following exception when I start 100 instances using Jmeter. I have attached my process definition and engine config files , kindly help.

———————————————————————————————————————-
Process definition:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="SpCall" name="SpCall">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask1" name="Service Task" activiti:async="true" activiti:class="com.sw.dbcall.DBCall"></serviceTask>
    <sequenceFlow id="flow2" name="" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <serviceTask id="servicetask2" name="Service Task" activiti:async="true" activiti:class="com.sw.dbcall.DBCall"></serviceTask>
    <sequenceFlow id="flow3" name="" sourceRef="servicetask1" targetRef="servicetask2"></sequenceFlow>
    <serviceTask id="servicetask3" name="Service Task" activiti:async="true" activiti:class="com.sw.dbcall.DBCall"></serviceTask>
    <sequenceFlow id="flow4" name="" sourceRef="servicetask2" targetRef="servicetask3"></sequenceFlow>
    <serviceTask id="servicetask4" name="Service Task" activiti:async="true" activiti:class="com.sw.dbcall.DBCall"></serviceTask>
    <sequenceFlow id="flow5" name="" sourceRef="servicetask3" targetRef="servicetask4"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow6" name="" sourceRef="servicetask4" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_SpCall">
    <bpmndi:BPMNPlane bpmnElement="SpCall" id="BPMNPlane_SpCall">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35" width="35" x="40" y="30"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
        <omgdc:Bounds height="55" width="105" x="90" y="90"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask2" id="BPMNShape_servicetask2">
        <omgdc:Bounds height="55" width="105" x="230" y="90"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask3" id="BPMNShape_servicetask3">
        <omgdc:Bounds height="55" width="105" x="370" y="110"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask4" id="BPMNShape_servicetask4">
        <omgdc:Bounds height="55" width="105" x="380" y="200"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35" width="35" x="540" y="210"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="57" y="65"></omgdi:waypoint>
        <omgdi:waypoint x="142" y="90"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="195" y="117"></omgdi:waypoint>
        <omgdi:waypoint x="230" y="117"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="335" y="117"></omgdi:waypoint>
        <omgdi:waypoint x="370" y="137"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="422" y="165"></omgdi:waypoint>
        <omgdi:waypoint x="432" y="200"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="485" y="227"></omgdi:waypoint>
        <omgdi:waypoint x="540" y="227"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

———————————————————————————————————————–
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

  <bean id="dbProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="classpath:db.properties" />
    <!– Allow other PropertyPlaceholderConfigurer to run as well –>
    <property name="ignoreUnresolvablePlaceholders" value="true"/>
  </bean>

 
    <!–<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
      <property name="driverClassName" value="${jdbc.driver}" />
      <property name="url" value="${jdbc.url}" />
      <property name="username" value="${jdbc.username}" />
      <property name="password" value="${jdbc.password}" />
       <property name="defaultAutoCommit" value="false" />
    </bean>
 
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
      <property name="driverClassName" value="com.mysql.jdbc.Driver" />
      <property name="url" value="jdbc:mysql://localhost:3306/activiti?autoReconnect=true" />
      <property name="username" value="root" />
      <property name="password" value="" />
       <property name="defaultAutoCommit" value="false" />
    </bean>   –>
   
    <!–   <bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
               <property name="driverClass" value="com.mysql.jdbc.Driver" />
               <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti?autoReconnect=true" />
               <property name="username" value="root"/>
               <property name="password" value=""/>
               <property name="idleConnectionTestPeriod" value="60"/>
               <property name="idleMaxAge" value="240"/>
               <property name="maxConnectionsPerPartition" value="30"/>
               <property name="minConnectionsPerPartition" value="10"/>
               <property name="partitionCount" value="5"/>
               <property name="acquireIncrement" value="5"/>
               <property name="statementsCacheSize" value="1000"/>
               <property name="releaseHelperThreads" value="3"/>
  </bean>–>
 
     
      <bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
                 <property name="driverClass" value="net.sourceforge.jtds.jdbc.Driver"/>
                 <property name="jdbcUrl" value="jdbc:jtds:sqlserver://xxx:1433/activiti"/>
                 <property name="username" value="sa"/>
                 <property name="password" value="xxx"/>
                 <property name="idleConnectionTestPeriod" value="60"/>
                 <property name="idleMaxAge" value="240"/>
                 <property name="maxConnectionsPerPartition" value="50"/>
                 <property name="minConnectionsPerPartition" value="10"/>
                 <property name="partitionCount" value="5"/>
                 <property name="acquireIncrement" value="5"/>
                 <property name="statementsCacheSize" value="1000"/>
                 <property name="releaseHelperThreads" value="3"/>
  </bean>
 
               
         
 

  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
  </bean>

<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
    <property name="dataSource" ref="dataSource" />
    <property name="transactionManager" ref="transactionManager"/>
    <property name="databaseSchemaUpdate" value="true"/>
    <property name="mailServerHost" value="localhost"/>
    <property name="mailServerPort" value="5025" />
    <property name="jobExecutorActivate" value="true"/>
   <property name="jobExecutor" ref="myJobExecutor"/>
  </bean>
 
<!–  <bean id="jobExecutor" class="org.activiti.engine.impl.jobexecutor.DefaultJobExecutor">
  <property name="corePoolSize" value="${activiti.jobExecutor.corePoolSize}"/>
  <property name="lockTimeInMillis" value="${activiti.jobExecutor.lockTimeInMillis}"/>
  <property name="maxJobsPerAcquisition" value="${activiti.jobExecutor.maxJobsPerAcquisition}"/>
  <property name="maxPoolSize" value="${activiti.jobExecutor.maxPoolSize}"/>
  <property name="queueSize" value="${activiti.jobExecutor.queueSize}"/>
  <property name="waitTimeInMillis" value="${activiti.jobExecutor.waitTimeInMillis}"/>
  </bean>–>
 
   
<bean id="myJobExecutor" class="org.activiti.engine.impl.jobexecutor.DefaultJobExecutor">
<property name="queueSize" value="30" />
<property name="corePoolSize" value="200" />
<property name="maxPoolSize" value="500" />
<property name="maxJobsPerAcquisition" value="300" />
<property name="waitTimeInMillis" value="1000" />
<property name="lockTimeInMillis" value="7200000"/>
</bean>

 


  <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  </bean>

</beans>
———————————————————————————————————————–
Thank you
Best Regards
Krishnendu
=========================
SEVERE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: java.sql.SQLException: Transaction (Process
ID 181) was deadlocked on lock resources with another process and has been chos
en as the deadlock victim. Rerun the transaction.
### The error may involve org.activiti.engine.impl.persistence.entity.ExecutionE
ntity.deleteExecution-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_EXECUTION where ID_ = ?
### Cause: java.sql.SQLException: Transaction (Process ID 181) was deadlocked on
lock resources with another process and has been chosen as the deadlock victim.
Rerun the transaction.
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(Exception
Factory.java:23)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSq
lSession.java:147)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSq
lSession.java:158)
        at org.activiti.engine.impl.db.DbSqlSession$DeleteById.execute(DbSqlSess
ion.java:146)
        at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.ja
va:483)
        at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:371)

        at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(Com
mandContext.java:157)
        at org.activiti.engine.impl.interceptor.CommandContext.close(CommandCont
ext.java:109)
        at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execut
e(CommandContextInterceptor.java:49)
        at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(Sp
ringTransactionInterceptor.java:42)
        at org.springframework.transaction.support.TransactionTemplate.execute(T
ransactionTemplate.java:130)
        at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransa
ctionInterceptor.java:40)
        at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterc
eptor.java:33)
        at org.activiti.engine.impl.jobexecutor.ExecuteJobsRunnable.run(ExecuteJ
obsRunnable.java:46)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:885)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:907)
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.SQLException: Transaction (Process ID 181) was deadlocked on
lock resources with another process and has been chosen as the deadlock victim.
Rerun the transaction.
        at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.j
ava:368)
        at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
        at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
        at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632)
        at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.
java:584)
        at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java
:546)
        at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.execute(JtdsPreparedS
tatement.java:558)
        at com.jolbox.bonecp.PreparedStatementHandle.execute(PreparedStatementHa
ndle.java:138)
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(
PreparedStatementHandler.java:41)
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(R
outingStatementHandler.java:66)
        at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.jav
a:45)
        at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)

        at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.jav
a:75)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSq
lSession.java:145)
        … 15 more
        at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)

        at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.jav
a:75)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSq
lSession.java:145)
        … 15 more

Outcomes