squito commented on a change in pull request #23871: [SPARK-23433][SPARK-25250] 
[CORE] Later created TaskSet should learn about the finished partitions 
URL: https://github.com/apache/spark/pull/23871#discussion_r262568722
 
 

 ##########
 File path: 
core/src/test/scala/org/apache/spark/scheduler/TaskSchedulerImplSuite.scala
 ##########
 @@ -1133,30 +1133,51 @@ class TaskSchedulerImplSuite extends SparkFunSuite 
with LocalSparkContext with B
       assert(tsm.runningTasks === 9)
       tsm
     }
+    // we've now got 2 zombie attempts, each with 9 tasks still active but 
zero active attempt
+    // in taskScheduler.
+
+    // finish partition 1,2 by completing the tasks before a new attempt for 
the same stage submit.
+    // And it's possible since the behaviour of submitting new attempt and 
handling successful task
+    // is from two different threads, which are "task-result-getter" and 
"dag-scheduler-event-loop"
+    // separately.
+    (0 until 2).foreach { i =>
+      completeTaskSuccessfully(zombieAttempts(i), i + 1)
+      assert(taskScheduler.stageIdToFinishedPartitions(0).contains(i + 1))
+    }
 
-    // we've now got 2 zombie attempts, each with 9 tasks still active.  
Submit the 3rd attempt for
-    // the stage, but this time with insufficient resources so not all tasks 
are active.
-
+    // Submit the 3rd attempt still with 10 tasks, this happens due to the 
race between thread
+    // "task-result-getter" and "dag-scheduler-event-loop", where a TaskSet 
gets submitted with
+    // already completed tasks. And this time with insufficient resources so 
not all tasks are
+    // active.
     val finalAttempt = FakeTask.createTaskSet(10, stageAttemptId = 2)
     taskScheduler.submitTasks(finalAttempt)
     val finalTsm = taskScheduler.taskSetManagerForAttempt(0, 2).get
+    // Though, finalTsm gets submitted after some tasks succeeds, but it could 
also know about the
+    // finished partition by looking into `stageIdToFinishedPartitions` when 
it is being created,
+    // so that it won't launch any duplicate tasks later.
 
 Review comment:
   I'd reword this to
   
   Though finalTSM gets submitted with 10 tasks, the call to 
`taskScheduler.submitTasks` should realize that 2 tasks have already completed, 
and mark them appropriately, so it won't launch any duplicate tasks later 
(SPARK-25250).

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to