Ngone51 commented on a change in pull request #27115: [SPARK-30440] Flaky test: 
org.apache.spark.scheduler.TaskSetManagerSuite
URL: https://github.com/apache/spark/pull/27115#discussion_r363722012
 
 

 ##########
 File path: 
core/src/test/scala/org/apache/spark/scheduler/TaskSetManagerSuite.scala
 ##########
 @@ -1928,9 +1928,15 @@ class TaskSetManagerSuite
     // get the TaskSetManager
     val manager = 
sched.invokePrivate(taskSetManagers()).get(stageId).get(stageAttemptId)
 
-    val task0 = manager.resourceOffer(exec0, "localhost", TaskLocality.NO_PREF)
-    val task1 = manager.resourceOffer(exec1, "localhost", TaskLocality.NO_PREF)
-    assert(task0.isDefined && task1.isDefined)
+    var task0 : Option[TaskInfo] = None
+    var task1 : Option[TaskInfo] = None
+
+    eventually(timeout(10.seconds), interval(100.milliseconds)) {
+      task0 = Option(manager.taskInfos(0))
+      task1 = Option(manager.taskInfos(1))
+      assert(task0.isDefined && task1.isDefined)
+    }
 
 Review comment:
   The race condition is between `sched.submitTasks` and 
`manager.resourceOffer`. That means, tasks within taskSet can be scheduled or 
even finished before we call `manager.resourceOffer`. If this happens, then 
`manager.resourceOff` would return `None`. In a worse case, the taskSet can be 
finished before we call `manager.resourceOffer`, then, `manager` can be null 
when we call 
`sched.invokePrivate(taskSetManagers()).get(stageId).get(stageAttemptId)`.  So 
it's still possible with this fix that tasks has already finished when we 
assert running status below.
   
   BTW, I believe that we don't need to wait `managers` to return `taskInfos`, 
as it always exists once we submit the taskset to `TaskSchedulerImpl`.

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