You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/01/02 06:40:31 UTC

[GitHub] [dolphinscheduler] caishunfeng commented on a change in pull request #7768: [Fix-7767]Task instance is not deleted while deleting the process instance

caishunfeng commented on a change in pull request #7768:
URL: https://github.com/apache/dolphinscheduler/pull/7768#discussion_r777171949



##########
File path: dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
##########
@@ -529,6 +529,39 @@ public void removeTaskLogFile(Integer processInstanceId) {
         }
     }
 
+    /**
+     * 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;
+        }
+
+        for (TaskInstance taskInstance : taskInstanceList) {
+            taskInstanceMapper.deleteById(taskInstance.getId());
+            removeTaskLogFile(taskInstance);
+        }
+    }
+
+    /**
+     * remove task log file by task instance
+     *
+     * @param taskInstance taskInstance
+     */
+    public void removeTaskLogFile(TaskInstance taskInstance) {
+        try (LogClientService logClient = new LogClientService()) {

Review comment:
       It seems that it can be operated by batch and don't have to create logClient and release every time.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org