From 42ba593ae440843a690aee3d127156bef174fb50 Mon Sep 17 00:00:00 2001 From: JinYong Li <42576980+JinyLeeChina@users.noreply.github.com> Date: Mon, 4 Jul 2022 15:31:04 +0800 Subject: [PATCH] [Fix-10762] [bug] Dependent tasks wait for the workflow to end (#10765) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * issue 8645 (#8811) Co-authored-by: 北笙 <“zhanqian@cai-inc.com”> Co-authored-by: zhanqian * [fix-8929][DAO]Description Failed to upload the file because the full name was too long (#9020) * [fix-8929][DAO]Description Failed to upload the file because the full name was too long * [DS-#8929][fix]Description Failed to upload the file because the full name was too long * [DS-#8929][fix]Description Failed to upload the file because the full name was too long * [DS-#8929][fix]Description Failed to upload the file because the full name was too long Co-authored-by: houshuai * [BUG][ALERT-SERVER]validate script before alert script (#9834) * validate script before alert script * fix validate script before alert script * pick 8811/9020/9834 * fix ut * fix pick error * fix 10762 Co-authored-by: zhanqian <360400325@qq.com> Co-authored-by: 北笙 <“zhanqian@cai-inc.com”> Co-authored-by: zhanqian Co-authored-by: shuai hou <120306274@qq.com> Co-authored-by: houshuai Co-authored-by: Tq Co-authored-by: JinyLeeChina --- .../service/impl/ResourcesServiceImpl.java | 1 + .../server/utils/DependentExecute.java | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) 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);