You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ca...@apache.org on 2022/01/03 07:52:58 UTC

[dolphinscheduler] branch dev updated: [Fix-7767]Task instance is not deleted while deleting the process instance (#7768)

This is an automated email from the ASF dual-hosted git repository.

caishunfeng pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 7395b98  [Fix-7767]Task instance is not deleted while deleting the process instance (#7768)
7395b98 is described below

commit 7395b980d3d76646dada5b7e9220d946b154001e
Author: xiangzihao <46...@qq.com>
AuthorDate: Mon Jan 3 15:52:50 2022 +0800

    [Fix-7767]Task instance is not deleted while deleting the process instance (#7768)
    
    * fix bug_7767
    
    * fix bug_7767
    
    * fix bug_7767
    
    * fix bug_7767
    
    * fix bug_7767
---
 .../api/service/impl/ProcessInstanceServiceImpl.java  |  1 +
 .../service/process/ProcessService.java               | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
index 195adcd..f4f1e2f 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
@@ -632,6 +632,7 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
 
         processService.deleteAllSubWorkProcessByParentId(processInstanceId);
         processService.deleteWorkProcessMapByParentId(processInstanceId);
+        processService.deleteWorkTaskInstanceByProcessInstanceId(processInstanceId);
 
         if (delete > 0) {
             putMsg(result, Status.SUCCESS);
diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
index a65f05b..4441bfb 100644
--- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
+++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
@@ -530,6 +530,25 @@ public class ProcessService {
     }
 
     /**
+     * recursive delete all task instance by process instance id
+     * @param processInstanceId
+     */
+    public void deleteWorkTaskInstanceByProcessInstanceId(int processInstanceId) {
+        List<TaskInstance> taskInstanceList = findValidTaskListByProcessId(processInstanceId);
+        if (CollectionUtils.isEmpty(taskInstanceList)) {
+            return;
+        }
+
+        List<Integer> taskInstanceIdList = new ArrayList<>();
+
+        for (TaskInstance taskInstance : taskInstanceList) {
+            taskInstanceIdList.add(taskInstance.getId());
+        }
+
+        taskInstanceMapper.deleteBatchIds(taskInstanceIdList);
+    }
+
+    /**
      * recursive query sub process definition id by parent id.
      *
      * @param parentCode parentCode