Hello,
i have encountered an exception 'SqlTransactionRollbackException' when i invoked the API 'taskService.complete(Strin taskId,map variables)' to complete a User Task frequently; The probability of encountering this exception is high to 40%.The User Task's property 'asynchronous' is set by 'false',and 'exclusive' is 'true'. what problem cause this exception? deadlock? WHY ?
Have you had a look at this forum page - Deadlock in DB2 ?
If you could provide a bit more detail or even better a code example that might help. How are you invoking the rest call? Are choosing from a list at random, one at a time or in parallel and at what rate?
First,thanks for your answer,Ryan!
I have changed the db2 locktimeout to 60 sec according to the comment on Deadlock in DB2 ,but it does't work.
my codes as below:
//1.get task
TaskEntity task = (TaskEntity) taskService.createTaskQuery().taskId(taskId).singleResult();
if(task==null){
throw new TimeException("this task has been finished");
}
//2.judge if have authority
List<IdentityLink> linkList=taskService.getIdentityLinksForTask(taskId);
boolean haveNotRight=true;
if(linkList!=null){
for(IdentityLink link:linkList){
if(approveUserId.equals(link.getUserId())){
haveNotRight=false;
}
}
}
if(haveNotRight){
throw new RunTimeException("no authority");
}
//3.get activiti variables map
Map<String, Object> variables =taskService.getTaskVariablesByTaskId(taskId);
ShareVO afterShareMain=(ShareVO)variables.get("afterShareMain");
String serviceDataOfOrgCode=(String)variables.get("serviceDataOfOrgCode");
//this api is to judge if the same net base on the datas from db2
Map<String,Object> isSame=this.isSameOrg(afterShareMain, serviceDataOfOrgCode);
int isSameNet="1".equals(isSame.get("isSameNet"))?1:0;
//4.put the parameter into the variables map
variables.put("result", Integer.parseInt(result));
variables.put("comments", comments);
variables.put("approveUserId", approveUserId);
variables.put("isSameNet",isSameNet);
//5. set local variable
taskService.setVariablesLocal(taskId, variables);
//6.complete the task
taskService.completeTask(taskId, variables);
Besides,i have used a TaskListener when create this UserTask(or act node),the TaskListener is to add candidate user to the UserTask( invoke the API 'DelegateTask.addCandidateUsers(String userId)').
by the way,encouting the SqlTransactionRollbackException always happened when the number of visiting our soft web is higher.
Thanks!
forget your question ne at a time , not in parallel! Thanks!
Thanks for elaborating. Actually I should have also asked about your Activiti setup. It seems like what you're seeing could match to this issue:
deadlocked while deleting records from ACT_RU_EXECUTION with multiple activiti engines running
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.