Solve transaction problems under multi-threading (#10917)
This commit is contained in:
parent
c450e7a5ac
commit
d1cf6fe86b
|
|
@ -312,18 +312,11 @@ public class ProcessServiceImpl implements ProcessService {
|
|||
//serial wait
|
||||
//when we get the running instance(or waiting instance) only get the priority instance(by id)
|
||||
if (processDefinition.getExecutionType().typeIsSerialWait()) {
|
||||
while (true) {
|
||||
List<ProcessInstance> runningProcessInstances = this.processInstanceMapper.queryByProcessDefineCodeAndProcessDefinitionVersionAndStatusAndNextId(processInstance.getProcessDefinitionCode(),
|
||||
processInstance.getProcessDefinitionVersion(), Constants.RUNNING_PROCESS_STATE, processInstance.getId());
|
||||
if (CollectionUtils.isEmpty(runningProcessInstances)) {
|
||||
processInstance.setState(ExecutionStatus.SUBMITTED_SUCCESS);
|
||||
saveProcessInstance(processInstance);
|
||||
return;
|
||||
}
|
||||
ProcessInstance runningProcess = runningProcessInstances.get(0);
|
||||
if (this.processInstanceMapper.updateNextProcessIdById(processInstance.getId(), runningProcess.getId())) {
|
||||
return;
|
||||
}
|
||||
List<ProcessInstance> runningProcessInstances = this.processInstanceMapper.queryByProcessDefineCodeAndProcessDefinitionVersionAndStatusAndNextId(processInstance.getProcessDefinitionCode(),
|
||||
processInstance.getProcessDefinitionVersion(), Constants.RUNNING_PROCESS_STATE, processInstance.getId());
|
||||
if (CollectionUtils.isEmpty(runningProcessInstances)) {
|
||||
processInstance.setState(ExecutionStatus.SUBMITTED_SUCCESS);
|
||||
saveProcessInstance(processInstance);
|
||||
}
|
||||
} else if (processDefinition.getExecutionType().typeIsSerialDiscard()) {
|
||||
List<ProcessInstance> runningProcessInstances = this.processInstanceMapper.queryByProcessDefineCodeAndProcessDefinitionVersionAndStatusAndNextId(processInstance.getProcessDefinitionCode(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue