cancel
Showing results for 
Search instead for 
Did you mean: 

deadlock in load test with db2

long_187
Champ in-the-making
Champ in-the-making
Load Test:
  2 concurrent;
  db2 v9.7;
  activiti v5.12
  weblogic 10

deadlock occuerd:

1190995 2013-04-08 16:48:08.176 [ACTIVE] ExecuteThread: '541' for queue: 'weblogic.kernel.Default (self-tuning)' true POST /aps/SubmitApsTask.param [f=SubmitApsTask, ti
d=, ip=197.3.176.106, sid=]
ERROR c.t.f.f.s.ExceptionHandleFilter - com.tesla.framework.filter.support.ExceptionHandleFilter
org.apache.ibatis.exceptions.PersistenceException:
### Error updating database.  Cause: com.ibm.db2.jcc.am.to: DB2 SQL Error: SQLCODE=-911, SQLSTATE=40001, SQLERRMC=2, DRIVER=3.58.82
### The error may involve org.activiti.engine.impl.persistence.entity.TaskEntity.deleteTask-Inline
### The error occurred while setting parameters
### SQL: delete from ACT_RU_TASK where ID_ = ? and REV_ = ?
### Cause: com.ibm.db2.jcc.am.to: DB2 SQL Error: SQLCODE=-911, SQLSTATE=40001, SQLERRMC=2, DRIVER=3.58.82
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23) ~[mybatis-3.1.1.jar:3.1.1]
        at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:147) ~[mybatis-3.1.1.jar:3.1.1]
        at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:158) ~[mybatis-3.1.1.jar:3.1.1]
        at org.activiti.engine.impl.db.DbSqlSession$DeletePersistentObjectOperation.execute(DbSqlSession.java:237) ~[activiti-engine-5.12.jar:5.12]
        at org.activiti.engine.impl.db.DbSqlSession.flushDeletes(DbSqlSession.java:668) ~[activiti-engine-5.12.jar:5.12]
        at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:462) ~[activiti-engine-5.12.jar:5.12]
        at org.activiti.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:168) ~[activiti-engine-5.12.jar:5.12]
        at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:115) ~[activiti-engine-5.12.jar:5.12]
        at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:70) ~[activiti-engine-5.12.jar:5.12]
        at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42) ~[activiti-spring-5.12.jar:na]
        at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130) ~[spring-tx-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40) ~[activiti-spring-5.12.jar:na]
        at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31) ~[activiti-engine-5.12.jar:5.12]
        at org.activiti.engine.impl.FormServiceImpl.submitTaskFormData(FormServiceImpl.java:70) ~[activiti-engine-5.12.jar:5.12]
        at com.tesla.bpmn.action.SubmitTaskFormDataAction.execute(SubmitTaskFormDataAction.java:25) ~[_wl_cls_gen.jar:na]
        at com.tesla.framework.function.impl.SequenceCallActionFunction.execute(SequenceCallActionFunction.java:22) ~[tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at com.tesla.framework.function.support.FunctionFilterChain.doFilter(FunctionFilterChain.java:31) ~[tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at com.tesla.framework.function.support.FunctionControllerFilterChain.doFilter(FunctionControllerFilterChain.java:31) [tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPS
HOT]
        at com.tesla.framework.admin.monitor.support.FunctionMonitorFilter.doFilter(FunctionMonitorFilter.java:117) ~[tesla-admin-monitor-0.0.1-20130325.021048-37.jar:0
.0.1-SNAPSHOT]
        at com.tesla.framework.function.support.FunctionControllerFilterChain.doFilter(FunctionControllerFilterChain.java:26) [tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPS
HOT]
        at com.tesla.framework.filter.support.ValidationFilter.doFilter(ValidationFilter.java:38) ~[tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at com.tesla.framework.function.support.FunctionControllerFilterChain.doFilter(FunctionControllerFilterChain.java:26) [tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPS
HOT]
        at com.tesla.framework.filter.support.ParameterFilter.doFilter(ParameterFilter.java:59) ~[tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at com.tesla.framework.function.support.FunctionControllerFilterChain.doFilter(FunctionControllerFilterChain.java:26) [tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPS
HOT]
        at com.tesla.framework.filter.support.FunctionControlFilter.doFilter(FunctionControlFilter.java:25) ~[tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at com.tesla.framework.function.support.FunctionControllerFilterChain.doFilter(FunctionControllerFilterChain.java:26) [tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPS
HOT]
        at com.tesla.framework.filter.support.ExceptionHandleFilter.doFilter(ExceptionHandleFilter.java:35) ~[tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at com.tesla.framework.function.support.FunctionControllerFilterChain.doFilter(FunctionControllerFilterChain.java:26) [tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPS
HOT]
        at com.tesla.framework.filter.support.FunctionMDCFilter.doFilter(FunctionMDCFilter.java:20) [tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at com.tesla.framework.function.support.FunctionControllerFilterChain.doFilter(FunctionControllerFilterChain.java:26) [tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPS
HOT]
        at com.tesla.framework.function.support.DefaultFunctionController.execute(DefaultFunctionController.java:39) [tesla-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at com.tesla.framework.channel.http.support.AbstractSpringHttpController.handleRequestInternal(AbstractSpringHttpController.java:65) [tesla-channel-http-0.0.1-2
0130323.070636-43.jar:0.0.1-SNAPSHOT]
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153) [spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) [spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELE
ASE]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) [spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) [spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915) [spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:822) [spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) [javax.servlet_1.0.0.0_2-5.jar:2.5]
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796) [spring-webmvc-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) [javax.servlet_1.0.0.0_2-5.jar:2.5]
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) [weblogic.jar:10.3.5.0]
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) [weblogic.jar:10.3.5.0]
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300) [weblogic.jar:10.3.5.0]
        at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) [weblogic.jar:10.3.5.0]
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) [weblogic.jar:10.3.5.0]
        at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) [shiro-web-1.2.1.jar:1.2.1]
        at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) [shiro-web-1.2.1.jar:1.2.1]
        at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) [shiro-core-1.2.1.jar:1.2.1]
        at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) [shiro-core-1.2.1.jar:1.2.1]
        at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) [shiro-core-1.2.1.jar:1.2.1]
        at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) [shiro-web-1.2.1.jar:1.2.1]
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) [shiro-web-1.2.1.jar:1.2.1]
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) [spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) [spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) [weblogic.jar:10.3.5.0]
        at com.tesla.framework.logconfig.servlet.SetLoggingContextFilter.doFilter(SetLoggingContextFilter.java:53) [tesla-logconfig-0.0.1-20130323.070641-27.jar:0.0.1-S
NAPSHOT]
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) [weblogic.jar:10.3.5.0]
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) [spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-3.2.0.RELEASE.jar:3.2.0.RELEASE]
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) [weblogic.jar:10.3.5.0]
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715) [weblogic.jar:10.3.5.0]
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681) [weblogic.jar:10.3.5.0]
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) [com.bea.core.weblogic.security.identity_1.1.2.1.jar:1.1.2.1]
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) [com.bea.core.weblogic.security.wls_1.0.0.0_6-1-0-0.jar:6.1.0.0]
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277) [weblogic.jar:10.3.5.0]
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183) [weblogic.jar:10.3.5.0]
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454) [weblogic.jar:10.3.5.0]
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) [com.bea.core.weblogic.workmanager_1.10.0.0.jar:1.10.0.0]
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:178) [com.bea.core.weblogic.workmanager_1.10.0.0.jar:1.10.0.0]
Caused by: com.ibm.db2.jcc.am.to: DB2 SQL Error: SQLCODE=-911, SQLSTATE=40001, SQLERRMC=2, DRIVER=3.58.82
        at com.ibm.db2.jcc.am.ed.a(ed.java:663) ~[db2jcc-9.0.jar:na]
        at com.ibm.db2.jcc.am.ed.a(ed.java:60) ~[db2jcc-9.0.jar:na]
        at com.ibm.db2.jcc.am.ed.a(ed.java:127) ~[db2jcc-9.0.jar:na]
        at com.ibm.db2.jcc.am.tm.c(tm.java:2523) ~[db2jcc-9.0.jar:na]
        at com.ibm.db2.jcc.t4.fb.s(fb.java:940) ~[db2jcc-9.0.jar:na]
        at com.ibm.db2.jcc.t4.fb.k(fb.java:390) ~[db2jcc-9.0.jar:na]
        at com.ibm.db2.jcc.t4.fb.a(fb.java:61) ~[db2jcc-9.0.jar:na]
        at com.ibm.db2.jcc.t4.t.a(t.java:50) ~[db2jcc-9.0.jar:na]
        at com.ibm.db2.jcc.t4.vb.b(vb.java:218) ~[db2jcc-9.0.jar:na]
        at com.ibm.db2.jcc.am.um.jc(um.java:2860) ~[db2jcc-9.0.jar:na]
        at com.ibm.db2.jcc.am.um.b(um.java:3795) ~[db2jcc-9.0.jar:na]
        at com.ibm.db2.jcc.am.um.cc(um.java:2250) ~[db2jcc-9.0.jar:na]
        at com.ibm.db2.jcc.am.um.execute(um.java:2234) ~[db2jcc-9.0.jar:na]
        at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172) ~[commons-dbcp-1.4.jar:1.4]
        at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172) ~[commons-dbcp-1.4.jar:1.4]
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41) ~[mybatis-3.1.1.jar:3.1.1]
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66) ~[mybatis-3.1.1.jar:3.1.1]
        at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45) ~[mybatis-3.1.1.jar:3.1.1]
        at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108) ~[mybatis-3.1.1.jar:3.1.1]
        at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75) ~[mybatis-3.1.1.jar:3.1.1]
        at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145) ~[mybatis-3.1.1.jar:3.1.1]
        … 68 common frames omitted
12 REPLIES 12

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Adding a unittest that demonstrates the problem would help tremendously…

jbarrez
Star Contributor
Star Contributor
Yes indeed, without it it gets very hard guessing what exactly is tested.

long_187
Champ in-the-making
Champ in-the-making
ApsProcess.bpmn:
<?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" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="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.cmbc.com.cn/test">
  <process id="apsProcess" name="网点预处理流程" isExecutable="true" activiti:candidateStarterGroups="businessManager">
    <documentation>网点预处理流程</documentation>
    <startEvent id="startevent" name="Start" activiti:initiator="initiator"></startEvent>
    <userTask id="approveTask" name="审核经理审核" activiti:candidateGroups="approver">
      <extensionElements>
        <activiti:formProperty id="name" name="姓名" type="string" expression="${name}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="sex" name="性别" type="enum" expression="${sex}" writable="false">
          <activiti:value id="male" name="男"></activiti:value>
          <activiti:value id="female" name="女"></activiti:value>
        </activiti:formProperty>
        <activiti:formProperty id="idType" name="证件类型" type="enum" expression="${idType}" writable="false">
          <activiti:value id="identification" name="身份证"></activiti:value>
          <activiti:value id="officerCard" name="军官证"></activiti:value>
        </activiti:formProperty>
        <activiti:formProperty id="idNum" name="证件号码" type="string" expression="${idNum}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="cardNum" name="卡号" type="string" expression="${cardNum}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="businessType" name="业务类型" type="string" expression="${businessType}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="amount" name="交易金额" type="string" expression="${amount}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="approved" name="是否审核通过" type="enum" required="true">
          <activiti:value id="true" name="是"></activiti:value>
          <activiti:value id="false" name="否"></activiti:value>
        </activiti:formProperty>
        <activiti:formProperty id="approveAdvice" name="审核意见" type="string"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="approveGatewayFlow" sourceRef="approveTask" targetRef="exclusivegateway1"></sequenceFlow>
    <sequenceFlow id="notApprovedFlow" name="审核不通过" sourceRef="exclusivegateway1" targetRef="commitTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${approved==false}]]></conditionExpression>
    </sequenceFlow>
    <parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="approvedNextFlow" name="审核通过" sourceRef="exclusivegateway1" targetRef="parallelgateway1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${approved==true}]]></conditionExpression>
    </sequenceFlow>
    <serviceTask id="prepCondition1" name="准备关键条件1" activiti:class="com.cmbc.aps.activiti.PrepareConditionOneDelegate"></serviceTask>
    <userTask id="prepCondition3" name="准备关键条件3" activiti:assignee="${initiator}">
      <extensionElements>
        <activiti:taskListener event="complete" class="com.cmbc.aps.activiti.PrepCondition3TaskListener"></activiti:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="toPrepCondition3Flow" sourceRef="parallelgateway1" targetRef="prepCondition3"></sequenceFlow>
    <sequenceFlow id="toPrepCondition1Flow" sourceRef="parallelgateway1" targetRef="prepCondition1"></sequenceFlow>
    <userTask id="processTask" name="处理任务" activiti:candidateGroups="counter">
      <extensionElements>
        <activiti:formProperty id="name" name="姓名" type="string" expression="${name}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="sex" name="性别" type="enum" expression="${sex}" writable="false">
          <activiti:value id="male" name="男"></activiti:value>
          <activiti:value id="female" name="女"></activiti:value>
        </activiti:formProperty>
        <activiti:formProperty id="idType" name="证件类型" type="enum" expression="${idType}" writable="false">
          <activiti:value id="identification" name="身份证"></activiti:value>
          <activiti:value id="officerCard" name="军官证"></activiti:value>
        </activiti:formProperty>
        <activiti:formProperty id="idNum" name="证件号码" type="string" expression="${idNum}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="cardNum" name="卡号" type="string" expression="${cardNum}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="businessType" name="业务类型" type="string" expression="${businessType}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="amount" name="交易金额" type="string" expression="${amount}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="successed" name="是否处理成功" type="enum" required="true">
          <activiti:value id="true" name="是"></activiti:value>
          <activiti:value id="false" name="否"></activiti:value>
        </activiti:formProperty>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow2" sourceRef="prepCondition1" targetRef="parallelgateway2"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="prepCondition3" targetRef="parallelgateway2"></sequenceFlow>
    <parallelGateway id="parallelgateway2" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="flow5" sourceRef="parallelgateway2" targetRef="processTask"></sequenceFlow>
    <exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow6" sourceRef="processTask" targetRef="exclusivegateway2"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="toFinish" name="处理成功" sourceRef="exclusivegateway2" targetRef="endevent1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${successed==true}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="exceptionHandle" name="异常处理" activiti:candidateGroups="exceptionHandler">
      <extensionElements>
        <activiti:formProperty id="name" name="姓名" type="string" expression="${name}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="sex" name="性别" type="enum" expression="${sex}" writable="false">
          <activiti:value id="male" name="男"></activiti:value>
          <activiti:value id="female" name="女"></activiti:value>
        </activiti:formProperty>
        <activiti:formProperty id="idType" name="证件类型" type="enum" expression="${idType}" writable="false">
          <activiti:value id="identification" name="身份证"></activiti:value>
          <activiti:value id="officerCard" name="军官证"></activiti:value>
        </activiti:formProperty>
        <activiti:formProperty id="idNum" name="证件号码" type="string" expression="${idNum}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="cardNum" name="卡号" type="string" expression="${cardNum}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="businessType" name="业务类型" type="string" expression="${businessType}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="amount" name="交易金额" type="string" expression="${amount}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="isSuccessed" type="string" default="业务未处理成功"></activiti:formProperty>
        <activiti:formProperty id="returnTo" name="任务退回给" type="enum" required="true">
          <activiti:value id="approver" name="审核经理"></activiti:value>
          <activiti:value id="businessManager" name="业务经理"></activiti:value>
        </activiti:formProperty>
      </extensionElements>
    </userTask>
    <sequenceFlow id="toExceptionHandle" name="处理不成功" sourceRef="exclusivegateway2" targetRef="exceptionHandle">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${successed==false}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="toStartFlow" name="退回给业务经理" sourceRef="exceptionHandle" targetRef="commitTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${returnTo=="businessManager"}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="toApproverFlow" name="退回给审核经理" sourceRef="exceptionHandle" targetRef="approveTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${returnTo=="approver"}]]></conditionExpression>
    </sequenceFlow>
    <scriptTask id="prepCondition2" name="准备关键条件2" scriptFormat="groovy">
      <script>condition2 = "OK";</script>
    </scriptTask>
    <sequenceFlow id="toPrepCondition2" sourceRef="parallelgateway1" targetRef="prepCondition2"></sequenceFlow>
    <sequenceFlow id="flow8" sourceRef="prepCondition2" targetRef="parallelgateway2"></sequenceFlow>
    <userTask id="commitTask" name="业务经理提交任务" activiti:candidateGroups="businessManager">
      <extensionElements>
        <activiti:formProperty id="name" name="姓名" type="string" required="true"></activiti:formProperty>
        <activiti:formProperty id="sex" name="性别" type="enum" required="true">
          <activiti:value id="male" name="男"></activiti:value>
          <activiti:value id="female" name="女"></activiti:value>
        </activiti:formProperty>
        <activiti:formProperty id="idType" name="证件类型" type="enum" required="true">
          <activiti:value id="identification" name="身份证"></activiti:value>
          <activiti:value id="officerCard" name="军官证"></activiti:value>
        </activiti:formProperty>
        <activiti:formProperty id="idNum" name="证件号码" type="string" required="true"></activiti:formProperty>
        <activiti:formProperty id="cardNum" name="卡号" type="string" required="true"></activiti:formProperty>
        <activiti:formProperty id="businessType" name="业务类型" type="string" required="true"></activiti:formProperty>
        <activiti:formProperty id="amount" name="交易金额" type="string" required="true"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow9" sourceRef="startevent" targetRef="commitTask"></sequenceFlow>
    <sequenceFlow id="flow10" sourceRef="commitTask" targetRef="approveTask"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_apsProcess">
    <bpmndi:BPMNPlane bpmnElement="apsProcess" id="BPMNPlane_apsProcess">
      <bpmndi:BPMNShape bpmnElement="startevent" id="BPMNShape_startevent">
        <omgdc:Bounds height="35.0" width="35.0" x="30.0" y="170.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="approveTask" id="BPMNShape_approveTask">
        <omgdc:Bounds height="55.0" width="105.0" x="241.0" y="160.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="380.0" y="167.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="490.0" y="167.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="processTask" id="BPMNShape_processTask">
        <omgdc:Bounds height="55.0" width="105.0" x="780.0" y="160.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway2" id="BPMNShape_parallelgateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="698.0" y="167.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway2" id="BPMNShape_exclusivegateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="812.0" y="247.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="919.0" y="250.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exceptionHandle" id="BPMNShape_exceptionHandle">
        <omgdc:Bounds height="55.0" width="105.0" x="241.0" y="321.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="prepCondition3" id="BPMNShape_prepCondition3">
        <omgdc:Bounds height="55.0" width="105.0" x="566.0" y="240.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="prepCondition2" id="BPMNShape_prepCondition2">
        <omgdc:Bounds height="55.0" width="105.0" x="566.0" y="160.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="prepCondition1" id="BPMNShape_prepCondition1">
        <omgdc:Bounds height="55.0" width="105.0" x="566.0" y="80.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="commitTask" id="BPMNShape_commitTask">
        <omgdc:Bounds height="55.0" width="105.0" x="100.0" y="160.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="notApprovedFlow" id="BPMNEdge_notApprovedFlow">
        <omgdi:waypoint x="400.0" y="167.0"></omgdi:waypoint>
        <omgdi:waypoint x="400.0" y="90.0"></omgdi:waypoint>
        <omgdi:waypoint x="170.0" y="90.0"></omgdi:waypoint>
        <omgdi:waypoint x="152.0" y="90.0"></omgdi:waypoint>
        <omgdi:waypoint x="152.0" y="160.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="100.0" x="-36.0" y="1.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="approvedNextFlow" id="BPMNEdge_approvedNextFlow">
        <omgdi:waypoint x="420.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="490.0" y="187.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="100.0" x="-30.0" y="0.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="671.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="718.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="718.0" y="207.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="738.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="780.0" y="187.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="671.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="718.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="718.0" y="167.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="832.0" y="215.0"></omgdi:waypoint>
        <omgdi:waypoint x="832.0" y="247.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="671.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="698.0" y="187.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="toStartFlow" id="BPMNEdge_toStartFlow">
        <omgdi:waypoint x="241.0" y="348.0"></omgdi:waypoint>
        <omgdi:waypoint x="152.0" y="348.0"></omgdi:waypoint>
        <omgdi:waypoint x="152.0" y="215.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="100.0" x="-44.0" y="-5.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="toApproverFlow" id="BPMNEdge_toApproverFlow">
        <omgdi:waypoint x="293.0" y="321.0"></omgdi:waypoint>
        <omgdi:waypoint x="293.0" y="215.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="100.0" x="10.0" y="0.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="toExceptionHandle" id="BPMNEdge_toExceptionHandle">
        <omgdi:waypoint x="832.0" y="287.0"></omgdi:waypoint>
        <omgdi:waypoint x="832.0" y="348.0"></omgdi:waypoint>
        <omgdi:waypoint x="346.0" y="348.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="100.0" x="10.0" y="0.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="toFinish" id="BPMNEdge_toFinish">
        <omgdi:waypoint x="852.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="919.0" y="267.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="100.0" x="-31.0" y="1.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="toPrepCondition1Flow" id="BPMNEdge_toPrepCondition1Flow">
        <omgdi:waypoint x="510.0" y="167.0"></omgdi:waypoint>
        <omgdi:waypoint x="509.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="566.0" y="107.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="toPrepCondition3Flow" id="BPMNEdge_toPrepCondition3Flow">
        <omgdi:waypoint x="510.0" y="207.0"></omgdi:waypoint>
        <omgdi:waypoint x="509.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="566.0" y="267.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="toPrepCondition2" id="BPMNEdge_toPrepCondition2">
        <omgdi:waypoint x="530.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="566.0" y="187.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="65.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="100.0" y="187.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
        <omgdi:waypoint x="205.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="241.0" y="187.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="approveGatewayFlow" id="BPMNEdge_approveGatewayFlow">
        <omgdi:waypoint x="346.0" y="187.0"></omgdi:waypoint>
        <omgdi:waypoint x="380.0" y="187.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

Unit test, ProcessTestApsProcess.java:
package org.activiti.designer.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.util.HashMap;
import java.util.Map;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.activiti.engine.test.ActivitiRule;
import org.databene.contiperf.PerfTest;
import org.databene.contiperf.junit.ContiPerfRule;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:activiti.cfg.xml")
public class ProcessTestApsProcess {

Logger logger = LoggerFactory.getLogger(getClass());

@Autowired
@Rule
public ActivitiRule activitiRule;

@Rule
public ContiPerfRule contiPerfRule = new ContiPerfRule();

@Test
@PerfTest(invocations = 500 , threads = 5)
//@Deployment(resources={"diagrams/ApsProcess.bpmn", "diagrams/ApsProcess.png"})
public void startProcess() throws Exception {
 
  try {
   RuntimeService runtimeService = activitiRule.getRuntimeService();
  
   //开预处理流程并提交任务
   activitiRule.getIdentityService().setAuthenticatedUserId("chenlong4");
  
   //String businessKey = "000004";
   ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("apsProcess");
   assertNotNull(processInstance.getId());
   System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
  
   final String processInstanceId = processInstance.getId();
  
   //业务经理提交任务
   Task businessManagerTask = activitiRule.getTaskService().createTaskQuery()
        .processInstanceId(processInstanceId)
        .taskCandidateGroup("businessManager")
        .active()
        .singleResult();
  
   activitiRule.getTaskService().claim(businessManagerTask.getId(), "chenlong4");
  
   Map<String, String> variableMap = new HashMap<String, String>();
   variableMap.put("name", "姓名");
   variableMap.put("sex", "male");
   variableMap.put("idType", "identification");
   variableMap.put("idNum", "430304XXXXXXXXXXXX");
   variableMap.put("cardNum", "6226220109108899");
   variableMap.put("businessType", "测试业务");
   variableMap.put("amount", "5000");
   activitiRule.getFormService().submitTaskFormData(businessManagerTask.getId(), variableMap);
  
   //审批经理审批
   Task approveTask = activitiRule.getTaskService().createTaskQuery()
        .processInstanceId(processInstanceId)
        .taskCandidateGroup("approver")
        .active()
        .singleResult();
  
   activitiRule.getTaskService().claim(approveTask.getId(), "xiaohong2");
  
   String approved = "true";
   Map<String, String> approvedProperties = new HashMap<String, String>();
   approvedProperties.put("approved", approved);
   activitiRule.getFormService().submitTaskFormData(approveTask.getId(), approvedProperties);
  
   //准备关键条件3
   Task prepareCondition3Task = activitiRule.getTaskService().createTaskQuery()
        .processInstanceId(processInstanceId)
        .taskAssignee("chenlong4")
        .active()
        .singleResult();
  
   activitiRule.getTaskService().complete(prepareCondition3Task.getId());
  
   //柜员处理任务
   Task processTask = activitiRule.getTaskService().createTaskQuery()
        .processInstanceId(processInstanceId)
        //.processInstanceBusinessKey(businessKey)
        .taskCandidateGroup("counter")
        .active()
        .singleResult();

  
   activitiRule.getTaskService().claim(processTask.getId(), "chenlong4");
  
   String successed = "true";
   Map<String, String> processProperties = new HashMap<String, String>();
   processProperties.put("successed", successed);
   activitiRule.getFormService().submitTaskFormData(processTask.getId(), processProperties);
  
   //完成
  
  
   processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
   assertEquals(true, processInstance == null);
  
//   HistoricProcessInstance hiProcessInstance = activitiRule.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
//   assertNotNull(hiProcessInstance);
  } catch (Throwable e) {
   logger.error("流程执行失败", e);
   Assert.fail(e.getMessage());
  }
}

}

long_187
Champ in-the-making
Champ in-the-making
Running Unit test "ProcessTestApsProcess.java" With only 2 thread will occur db2 deadlock, and the deadlock caused by method TaskService.submitTaskFormData()

long_187
Champ in-the-making
Champ in-the-making
I delete all forignkeys on tables ACT_RU_* the deadlock is gone.   Smiley Wink

I use db2 command "db2 get snapshot locks on db ACTIVITI" can find table ACT_RU_INDENTITY_LINK adnd ACT_RU_TASK are in "locked wait" status.
But I not know the real reason of the deadlock occured, why these tables will locked wait running in multiple thread?

jbarrez
Star Contributor
Star Contributor
Hmm. I got a feeling about this one: we released yesterday Activiti 5.12.1 which contains a bugfix related to the area you mention here. Could you give the new version a try and report back if the error still exists?

long_187
Champ in-the-making
Champ in-the-making
Activiti 5.12.1 did not work. I have retry my unit test with Activiti 5.12.1, still deadlock, and I have deleted all forignkeys on tables ACT_RU_* the deadlock is gone.

jbarrez
Star Contributor
Star Contributor
<i>Activiti 5.12.1 did not work. I have retry my unit test with Activiti 5.12.1, still deadlock, </i>

Damn. I really thought it would have fixed it. Bummers.

<i>and I have deleted all forignkeys on tables ACT_RU_* the deadlock is gone.</i>

That's really strange that it deadlocks because of foreign keys. That doesn't really makes sense.
Do you know which foreign key specifically?

long_187
Champ in-the-making
Champ in-the-making
It is not strange that it deadlocks because of foreign keys in db2.

But I think the real reason of deadlock may not be because of the foreign keys.

I have repeatedly run the unit tests ,and found these foreign keys cause the deadlock:

ALTER TABLE SCM_ACTIVITI.ACT_RU_IDENTITYLINK DROP CONSTRAINT ACT_FK_TSKASS_TASK;

ALTER TABLE SCM_ACTIVITI.ACT_RU_IDENTITYLINK DROP CONSTRAINT ACT_FK_IDL_PROCINST;

ALTER TABLE SCM_ACTIVITI.ACT_RU_TASK DROP CONSTRAINT ACT_FK_TASK_EXE;

ALTER TABLE SCM_ACTIVITI.ACT_RU_TASK DROP CONSTRAINT ACT_FK_TASK_PROCINST;

ALTER TABLE SCM_ACTIVITI.ACT_RU_VARIABLE DROP CONSTRAINT ACT_FK_VAR_EXE;

ALTER TABLE SCM_ACTIVITI.ACT_RU_VARIABLE DROP CONSTRAINT ACT_FK_VAR_PROCINST;

ALTER TABLE SCM_ACTIVITI.ACT_RU_EXECUTION DROP CONSTRAINT ACT_FK_EXE_PARENT;

ALTER TABLE SCM_ACTIVITI.ACT_RU_EXECUTION DROP CONSTRAINT ACT_FK_EXE_PROCINST;

ALTER TABLE SCM_ACTIVITI.ACT_RU_EXECUTION DROP CONSTRAINT ACT_FK_EXE_SUPER;