kevinjmh commented on code in PR #11490:
URL: https://github.com/apache/dolphinscheduler/pull/11490#discussion_r999028469


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java:
##########
@@ -1025,11 +1025,26 @@ public void deleteProcessDefinitionByCode(User 
loginUser, long code) {
             logger.error("Delete process definition error, 
processDefinitionCode:{}.", code);
             throw new 
ServiceException(Status.DELETE_PROCESS_DEFINE_BY_CODE_ERROR);
         }
-        int deleteRelation = 
processTaskRelationMapper.deleteByCode(project.getCode(), 
processDefinition.getCode());
-        if (deleteRelation == 0) {
-            logger.warn(
+        processDefinitionLogMapper.deleteByProcessDefinitionCode(code);
+        List<ProcessTaskRelation> processTaskRelations =
+                
processTaskRelationMapper.queryByProcessCode(project.getCode(), code);
+        if (!processTaskRelations.isEmpty()) {
+            int deleteRelation = 
processTaskRelationMapper.deleteByCode(project.getCode(), code);
+            if (deleteRelation == 0) {
+                logger.warn(
                     "The process definition has not relation, it will be 
delete successfully, processDefinitionCode:{}.",
                     code);
+            } else {
+                processTaskRelationLogMapper.deleteByProcessCode(code);

Review Comment:
   move this out. It could have old relation log that is not in newest workflow 
but belongs to the workflow



-- 
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: [email protected]

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

Reply via email to