From 0ba4263d9019d95a242ac3cef9de2c903692beb0 Mon Sep 17 00:00:00 2001 From: wind Date: Sun, 16 Jan 2022 18:51:38 +0800 Subject: [PATCH] [2.0.3][Bug-7986] Disable deletion of running workflow (#8064) Co-authored-by: caishunfeng <534328519@qq.com> --- .../api/service/impl/ProcessInstanceServiceImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 617d2ae937..57171c7089 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 @@ -623,6 +623,12 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, String.valueOf(processInstanceId)); return result; } + //check process instance status + if (!processInstance.getState().typeIsFinished()) { + putMsg(result, Status.PROCESS_INSTANCE_STATE_OPERATION_ERROR, + processInstance.getName(), processInstance.getState().toString(), "delete"); + return result; + } ProcessDefinition processDefinition = processDefineMapper.queryByCode(processInstance.getProcessDefinitionCode()); if (processDefinition != null && projectCode != processDefinition.getProjectCode()) { @@ -632,7 +638,8 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce try { processService.removeTaskLogFile(processInstanceId); - } catch (Exception e) { + } catch (Exception ignore) { + // ignore } // delete database cascade