AnsweredAssumed Answered

deadlock or timeout exception while persisting or retrieving tasks

Question asked by satya1 on Aug 4, 2015
Hi ,

I am seeing frequent deadlock or timeout exceptions while retrieving or persisting tasks from Activiti.

Are (org.activiti.engine.task.Comment, org.activiti.engine.task.Task) objects have any transaction management associated with them, should they be short lived or can they be iterated over a loop and other DB operations can be performed inside the context.

for (org.activiti.engine.task.Comment activitiComment : activitiCommentList) {
        comment = getNewComment();
        comment.setComment(activitiComment.getFullMessage());
        comment.setTimestamp(activitiComment.getTime());
        comment.setCommentType(activitiComment.getType());
       // DB call to get User name from use ID retrieved from "activitiComment" object – Can we do this DB call? or will it lock any table rows in  "ACT_HI_PROCINST"  table.
}
       
Exception stack traces below :

### The error may exist in org/activiti/db/mapping/entity/HistoricProcessInstance.xml
### The error may involve org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity.selectHistoricProcessInstancesByQueryCriteria-Inline
### The error occurred while setting parameters
### SQL: SELECT SUB.* FROM (select RES.* , row_number() over (ORDER BY RES.ID_ asc) rnk FROM ( select distinct RES.*              from TCTCA00.ACT_HI_PROCINST RES WHERE  RES.START_TIME_ <= ? and RES.START_TIME_ >= ? and RES.END_TIME_ IS NULL )RES ) SUB WHERE SUB.rnk >= ? AND SUB.rnk < ?
### Cause: com.ibm.db2.jcc.am.SqlTransactionRollbackException: The current transaction has been rolled back because of a deadlock or timeout.  Reason code "68".. SQLCODE=-911, SQLSTATE=40001, DRIVER=4.12.55#The current transaction has been rolled back because of a deadlock or timeout.  Reason code "68".. SQLCODE=-911, SQLSTATE=40001, DRIVER=4.12.55#ERROR_STACK_TRACE=org.apache.ibatis.exceptions.PersistenceException: @LF### Error querying database.  Cause: com.ibm.db2.jcc.am.SqlTransactionRollbackException: The current transaction has been rolled back because of a deadlock or timeout.  Reason code "68".. SQLCODE=-911, SQLSTATE=40001, DRIVER=4.12.55@LF### The error may exist in org/activiti/db/mapping/entity/HistoricProcessInstance.xml@LF### The error may involve org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity.selectHistoricProcessInstancesByQueryCriteria-Inline@LF### The error occurred while setting parameters@LF### SQL: SELECT SUB.* FROM (     select RES.* , row_number() over (ORDER BY RES.ID_ asc) rnk FROM ( select distinct RES.*              from TCTCA00.ACT_HI_PROCINST RES                            WHERE  RES.START_TIME_ <= ?                       and RES.START_TIME_ >= ?                                            and RES.END_TIME_ IS NULL                   )RES ) SUB WHERE SUB.rnk >= ? AND SUB.rnk < ?@LF### Cause: com.ibm.db2.jcc.am.SqlTransactionRollbackException: The current transaction has been rolled back because of a deadlock or timeout.  Reason code "68".. SQLCODE=-911, SQLSTATE=40001, DRIVER=4.12.55@LF      at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)@LF  at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107)@LF       at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)@LF     at org.activiti.engine.impl.db.DbSqlSession.selectListWithRawParameter(DbSqlSession.java:331)@LF    at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:322)@LF at org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntityManager.findHistoricProcessInstancesByQueryCriteria(HistoricProcessInstanceEntityManager.java:100)@LF    at org.activiti.engine.impl.HistoricProcessInstanceQueryImpl.executeList(HistoricProcessInstanceQueryImpl.java:235)@LF  at org.activiti.engine.impl.AbstractQuery.execute(AbstractQuery.java:139)@LF at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)@LF       at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)@LF      at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)@LF  at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131)@LF      at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)@LF at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)@LF       at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)@LF at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)@LF      at org.activiti.engine.impl.AbstractQuery.list(AbstractQuery.java:113)@LF       at

Different stack trace in another scenario:

### Error querying database.  Cause: com.ibm.db2.jcc.am.SqlTransactionRollbackException: The current transaction has been rolled back because of a deadlock or timeout.  Reason code "2".. SQLCODE=-911, SQLSTATE=40001, DRIVER=4.12.55
### The error may exist in org/activiti/db/mapping/entity/Task.xml
### The error may involve org.activiti.engine.impl.persistence.entity.TaskEntity.selectTasksByParentTaskId-Inline
### The error occurred while setting parameters
### SQL: select * from TCTCA00.ACT_RU_TASK where PARENT_TASK_ID_ = ?
### Cause: com.ibm.db2.jcc.am.SqlTransactionRollbackException: The current transaction has been rolled back because of a deadlock or timeout.  Reason code "2".. SQLCODE=-911, SQLSTATE=40001, DRIVER=4.12.55
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
        at org.activiti.engine.impl.db.DbSqlSession.selectListWithRawParameter(DbSqlSession.java:331)
        at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:322)
        at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:317)
        at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:298)
        at org.activiti.engine.impl.persistence.entity.TaskEntityManager.findTasksByParentTaskId(TaskEntityManager.java:172)
        at org.activiti.engine.impl.persistence.entity.TaskEntityManager.deleteTask(TaskEntityManager.java:61)
        at org.activiti.engine.impl.persistence.entity.TaskEntity.complete(TaskEntity.java:189)
        at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:50)
        at org.activiti.engine.impl.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:24)
        at org.activiti.engine.impl.cmd.NeedsActiveTaskCmd.execute(NeedsActiveTaskCmd.java:61)
        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.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
        at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131)
        at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
        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.TaskServiceImpl.complete(TaskServiceImpl.java:170)

Outcomes