yangyichao-mango commented on a change in pull request #3582:
URL: 
https://github.com/apache/incubator-dolphinscheduler/pull/3582#discussion_r477321185



##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
##########
@@ -488,6 +488,12 @@ private String getResourceIds(ProcessData processData) {
             putMsg(result, Status.PROCESS_DEFINE_STATE_ONLINE, 
processDefinitionId);
             return result;
         }
+        // check process instances is already running
+        List<ProcessInstance> processInstances =  
processInstanceMapper.queryByProcessDefineIdAndStatus(processDefinitionId, 
Constants.NOT_TERMINATED_STATES);
+        if (CollectionUtils.isNotEmpty(processInstances)) {
+            putMsg(result, 
Status.DELETE_PROCESS_DEFINITION_BY_ID_FAIL,processInstances.size());
+            return result;
+        }

Review comment:
       ```suggestion
           List<ProcessInstance> processInstances =  
processInstanceService.queryByProcessDefineIdAndStatus(processDefinitionId, 
Constants.NOT_TERMINATED_STATES);
           if (CollectionUtils.isNotEmpty(processInstances)) {
               putMsg(result, 
Status.DELETE_PROCESS_DEFINITION_BY_ID_FAIL,processInstances.size());
               return result;
           }
   ```
   
   Hi,
   In `processDefinitionService` service layer, it is not recommended 
straightly use `processInstanceMapper` dao layer, this part should be in 
`processInstanceService`, use `processInstanceService` here. 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to