diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java index 3698ea0bf8..c00d454614 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java @@ -64,6 +64,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.UUID; import java.util.regex.Matcher; diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/DependentExecute.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/DependentExecute.java index 77af8699f5..a26e8c6e29 100644 --- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/DependentExecute.java +++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/DependentExecute.java @@ -115,16 +115,16 @@ public class DependentExecute { dependentItem.getDefinitionCode(), dependentItem.getDepTaskCode()); return DependResult.WAITING; } - if (!processInstance.getState().typeIsFinished()) { - logger.info("Wait for the dependent workflow to complete, processDefiniteCode:{}, taskCode:{}, processInstanceId:{}, processInstance state:{}", - dependentItem.getDefinitionCode(), dependentItem.getDepTaskCode(), processInstance.getId(), processInstance.getState()); - return DependResult.WAITING; - } // need to check workflow for updates, so get all task and check the task state if (dependentItem.getDepTaskCode() == Constants.DEPENDENT_ALL_TASK_CODE) { + if (!processInstance.getState().typeIsFinished()) { + logger.info("Wait for the dependent workflow to complete, processDefiniteCode:{}, taskCode:{}, processInstanceId:{}, processInstance state:{}", + dependentItem.getDefinitionCode(), dependentItem.getDepTaskCode(), processInstance.getId(), processInstance.getState()); + return DependResult.WAITING; + } result = dependResultByProcessInstance(processInstance, dateInterval); } else { - result = getDependTaskResult(dependentItem.getDepTaskCode(), dateInterval); + result = getDependTaskResult(processInstance, dependentItem.getDepTaskCode(), dateInterval); } if (result != DependResult.SUCCESS) { break; @@ -192,10 +192,15 @@ public class DependentExecute { /** * get depend task result */ - private DependResult getDependTaskResult(long taskCode, DateInterval dateInterval) { + private DependResult getDependTaskResult(ProcessInstance processInstance, long taskCode, DateInterval dateInterval) { TaskInstance taskInstance = processService.findLastTaskInstanceInterval(taskCode, dateInterval); DependResult result; if (taskInstance == null) { + if (!processInstance.getState().typeIsFinished()) { + logger.info("Wait for the dependent workflow to complete, taskCode:{}, processInstanceId:{}, processInstance state:{}", + taskCode, processInstance.getId(), processInstance.getState()); + return DependResult.WAITING; + } TaskDefinition taskDefinition = processService.findTaskDefinitionByCode(taskCode); if (taskDefinition == null) { logger.error("Cannot find the task definition, something error, taskCode: {}", taskCode);