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/06 12:16:15 UTC

[GitHub] [dolphinscheduler] caishunfeng commented on a change in pull request #7808: [Bug-7788][MasterServer] fix submit duplicate tasks sometimes when retry

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



##########
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()) {

Review comment:
       > Is it necessary to query task instance from db?
   
   Yes, because the task instance in memory was not up to date.




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