Skip to content

Commit 5614699

Browse files
authored
[Fix-17050][Master] Fix workflow graph topology logical error (#17051)
1 parent 1c361bb commit 5614699

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/graph/WorkflowGraphTopologyLogicalVisitor.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,26 @@ private void doVisitationInSubGraph(Set<String> subGraphNodes) {
131131
.filter(entry -> entry.getValue() == 0)
132132
.map(Map.Entry::getKey)
133133
.collect(Collectors.toCollection(LinkedList::new));
134+
// Visited table, used to record the visited nodes
135+
Set<String> visitedTaskCodes = new HashSet<>();
134136

135137
while (!bootstrapTaskCodes.isEmpty()) {
136138
String taskName = bootstrapTaskCodes.removeFirst();
137139
if (inDegreeMap.get(taskName) > 0) {
138140
continue;
139141
}
140-
final Set<String> successors = workflowGraph.getSuccessors(taskName);
141-
if (subGraphNodes.contains(taskName)) {
142-
visitFunction.accept(taskName, successors);
142+
// Visit only when the in-degree is 0
143+
if (!visitedTaskCodes.contains(taskName)) {
144+
visitedTaskCodes.add(taskName); // Record the nodes
145+
final Set<String> successors = workflowGraph.getSuccessors(taskName);
146+
if (subGraphNodes.contains(taskName)) {
147+
visitFunction.accept(taskName, successors);
148+
}
149+
for (String successor : successors) {
150+
inDegreeMap.put(successor, inDegreeMap.get(successor) - 1);
151+
}
152+
bootstrapTaskCodes.addAll(successors);
143153
}
144-
for (String successor : successors) {
145-
inDegreeMap.put(successor, inDegreeMap.get(successor) - 1);
146-
}
147-
bootstrapTaskCodes.addAll(successors);
148154
}
149155
}
150156

0 commit comments

Comments
 (0)