fix workflow keep running when task fail (#11930)

This commit is contained in:
caishunfeng 2022-09-15 09:06:10 +08:00 committed by GitHub
parent e70c501f9a
commit 6868876a29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,6 +116,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
/**
* Workflow execute task, used to execute a workflow instance.
@ -180,9 +181,9 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> {
private final Map<Long, Integer> completeTaskMap = new ConcurrentHashMap<>();
/**
* depend failed task map, taskCode as key, taskId as value
* depend failed task set
*/
private final Map<Long, Integer> dependFailedTaskMap = new ConcurrentHashMap<>();
private final Set<Long> dependFailedTaskSet = Sets.newConcurrentHashSet();
/**
* forbidden task map, code as key
@ -805,7 +806,7 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> {
taskFailedSubmit = false;
activeTaskProcessorMaps.clear();
dependFailedTaskMap.clear();
dependFailedTaskSet.clear();
completeTaskMap.clear();
errorTaskMap.clear();
@ -908,8 +909,8 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> {
}
}
}
logger.info("Initialize task queue, dependFailedTaskMap: {}, completeTaskMap: {}, errorTaskMap: {}",
dependFailedTaskMap,
logger.info("Initialize task queue, dependFailedTaskSet: {}, completeTaskMap: {}, errorTaskMap: {}",
dependFailedTaskSet,
completeTaskMap,
errorTaskMap);
}
@ -1494,7 +1495,7 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> {
if (this.errorTaskMap.size() > 0) {
return true;
}
return this.dependFailedTaskMap.size() > 0;
return this.dependFailedTaskSet.size() > 0;
}
/**
@ -1845,7 +1846,7 @@ public class WorkflowExecuteRunnable implements Callable<WorkflowSubmitStatue> {
}
} else if (DependResult.FAILED == dependResult) {
// if the dependency fails, the current node is not submitted and the state changes to failure.
dependFailedTaskMap.put(task.getTaskCode(), task.getId());
dependFailedTaskSet.add(task.getTaskCode());
removeTaskFromStandbyList(task);
logger.info("Task dependent result is failed, taskInstanceId:{} depend result : {}", task.getId(),
dependResult);