zhongjiajie commented on a change in pull request #7808:
URL: https://github.com/apache/dolphinscheduler/pull/7808#discussion_r779251963



##########
File path: 
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/WorkflowExecuteThread.java
##########
@@ -1171,11 +1172,33 @@ private DependResult 
getDependResultForTask(TaskInstance taskInstance) {
      * @param taskInstance task instance
      */
     private void addTaskToStandByList(TaskInstance taskInstance) {
-        logger.info("add task to stand by list, task name: {} , task id:{}", 
taskInstance.getName(), taskInstance.getId());
         try {
-            if (!readyToSubmitTaskQueue.contains(taskInstance)) {
-                readyToSubmitTaskQueue.put(taskInstance);
+            // need to check if the tasks with same task code is active
+            boolean exist = false;
+            Map<Integer, TaskInstance> taskInstanceMap = 
taskInstanceHashMap.column(taskInstance.getTaskCode());
+            if (taskInstanceMap != null && taskInstanceMap.size() > 0) {
+                for (Entry<Integer, TaskInstance> entry : 
taskInstanceMap.entrySet()) {
+                    Integer taskInstanceId = entry.getKey();
+                    if (activeTaskProcessorMaps.containsKey(taskInstanceId)) {
+                        TaskInstance latestTaskInstance = 
processService.findTaskInstanceById(taskInstanceId);
+                        if (latestTaskInstance != null && 
!latestTaskInstance.getState().typeIsFailure()) {
+                            exist = true;
+                            break;
+                        }
+                    }
+                }
+            }
+            if (exist) {
+                logger.warn("task was found in active task list, task 
code:{}", taskInstance.getTaskCode());
+                return;
+            }
+            if (readyToSubmitTaskQueue.contains(taskInstance)) {
+                logger.warn("task was found in ready submit queue, task 
code:{}", taskInstance.getTaskCode());
+                return;
             }
+            logger.info("add task to stand by list, task name: {}, task id:{}, 
task code:{}",

Review comment:
       ```suggestion
               logger.info("add task to stand by list, task name:{}, task 
id:{}, task code:{}",
   ```




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