Github user kayousterhout commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11996#discussion_r64658256
  
    --- Diff: 
core/src/test/scala/org/apache/spark/scheduler/TaskSetManagerSuite.scala ---
    @@ -789,6 +791,52 @@ class TaskSetManagerSuite extends SparkFunSuite with 
LocalSparkContext with Logg
         assert(TaskLocation("executor_host1_3") === 
ExecutorCacheTaskLocation("host1", "3"))
       }
     
    +  test("Kill other task attempts when one attempt belonging to the same 
task succeeds") {
    +    sc = new SparkContext("local", "test")
    +    val sched = new FakeTaskScheduler(sc, ("exec1", "host1"), ("exec2", 
"host2"))
    +    val taskSet = FakeTask.createTaskSet(4)
    +    val manager = new TaskSetManager(sched, taskSet, MAX_TASK_FAILURES)
    +    val accumUpdatesByTask: Array[Seq[AccumulatorV2[_, _]]] = 
taskSet.tasks.map { task =>
    +      task.metrics.internalAccums
    +    }
    +    // Offer resources for 4 tasks to start
    +    for ((k, v) <- List(
    +        "exec1" -> "host1",
    +        "exec1" -> "host1",
    +        "exec2" -> "host2",
    +        "exec2" -> "host2")) {
    +      val taskOption = manager.resourceOffer(k, v, NO_PREF)
    +      assert(taskOption.isDefined)
    +      val task = taskOption.get
    +      assert(task.executorId === k)
    +    }
    +    assert(sched.startedTasks.toSet === Set(0, 1, 2, 3))
    +    // Complete the 3 tasks and leave 1 task in running
    +    for (id <- Set(0, 1, 2)) {
    +      manager.handleSuccessfulTask(id, createTaskResult(id, 
accumUpdatesByTask(id)))
    +      assert(sched.endedTasks(id) === Success)
    +    }
    +
    +    // Wait for the threshold time to start speculative attempt for the 
running task
    +    Thread.sleep(100)
    +    assert(manager.checkSpeculatableTasks)
    +    // Offer resource to start the speculative attempt for the running task
    +    val taskOption5 = manager.resourceOffer("exec1", "host1", NO_PREF)
    +    assert(taskOption5.isDefined)
    +    val task5 = taskOption5.get
    +    assert(task5.taskId === 4)
    +    assert(task5.executorId === "exec1")
    +    assert(task5.attemptNumber === 1)
    +    sched.backend = mock(classOf[SchedulerBackend])
    +    // Complete the speculative attempt for the running task
    +    manager.handleSuccessfulTask(4, createTaskResult(3, 
accumUpdatesByTask(3)))
    +    // It ends the task with success status as part of 
manager.handleSuccessfulTask() and
    --- End diff --
    
    I see what's going on here now -- can you change this comment to something 
like "Because the SchedulerBackend was a mock, the 2nd copy of the task won't 
actually be killed, so the FakeTaskScheduler is only told about the successful 
completion of the speculated task."  I think it would be also helpful to move 
the verify(...) call to be before this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to