Github user squito commented on a diff in the pull request:
https://github.com/apache/spark/pull/5636#discussion_r35457554
--- Diff:
core/src/test/scala/org/apache/spark/scheduler/DAGSchedulerSuite.scala ---
@@ -473,6 +473,146 @@ class DAGSchedulerSuite
assertDataStructuresEmpty()
}
+ test("Multiple consecutive stage failures should lead to stage being
aborted.") {
+ // Create a new Listener to confirm that the listenerBus sees the
JobEnd message
+ // when we abort the stage. This message will also be consumed by the
EventLoggingListener
+ // so this will propagate up to the user.
+ var ended = false
+ var jobResult : JobResult = null
+ class EndListener extends SparkListener {
+ override def onJobEnd(jobEnd: SparkListenerJobEnd): Unit = {
+ jobResult = jobEnd.jobResult
+ ended = true
+ }
+ }
+
+ sc.listenerBus.addListener(new EndListener())
+
+ val shuffleMapRdd = new MyRDD(sc, 2, Nil)
+ val shuffleDep = new ShuffleDependency(shuffleMapRdd, null)
+ val shuffleId = shuffleDep.shuffleId
+ val reduceRdd = new MyRDD(sc, 2, List(shuffleDep))
+ submit(reduceRdd, Array(0, 1))
+
+ complete(taskSets(0), Seq(
+ (Success, makeMapStatus("hostA", 2)),
+ (Success, makeMapStatus("hostB", 2))))
+
+ for (x <- 1 to Stage.MAX_STAGE_FAILURES) {
+ // the 2nd ResultTask failed
+ complete(taskSets(1), Seq(
+ (Success, 42),
+ (FetchFailed(makeBlockManagerId("hostA"), shuffleId, 0, 0,
"ignored"), null)))
--- End diff --
I think you want to keep taking the *last* task set. That will flip
between an attempt of stage 0 or stage, and then you complete accordingly.
Something like:
```scala
...
val reduceRdd = new MyRDD(sc, 2, List(shuffleDep))
submit(reduceRdd, Array(0, 1))
for (attempt <- 0 until Stage.MAX_STAGE_FAILURES) {
println(s"$attempt(a): taskSets = $taskSets :
${taskSets.map{_.tasks.mkString(",")}.mkString(";")}")
// complete all the tasks for the current attempt of stage 0
successfully
val stage0Attempt = taskSets.last
assert(stage0Attempt.stageId === 0)
assert(stage0Attempt.stageAttemptId == attempt)
println(s"tasks for $stage0Attempt :
${stage0Attempt.tasks.mkString(",")}")
val completions = stage0Attempt.tasks.zipWithIndex.map{ case (task,
idx) =>
(Success, makeMapStatus("host" + ('A' + idx).toChar, 2))
}.toSeq
complete(stage0Attempt, completions)
println(s"$attempt(b): taskSets = $taskSets :
${taskSets.map{_.tasks.mkString(",")}.mkString(";")}")
// now we should have a new taskSet, for a new attempt of stage 1.
We will have one fetch failure for this task
// set, and we'll complete the other tasks normally.
val stage1Attempt = taskSets.last
assert(stage1Attempt.stageId === 1)
assert(stage1Attempt.stageAttemptId === attempt)
println(s"tasks for $stage1Attempt :
${stage1Attempt.tasks.mkString(",")}")
val stage1Successes = stage1Attempt.tasks.tail.map { _ => (Success,
42)}
complete(stage1Attempt,
Seq((FetchFailed(makeBlockManagerId("hostA"), shuffleId, 0, 0,
"ignored"), null))
++ stage1Successes
)
// this will (potentially) trigger a resubmission of stage 0, since
we've lost some of its map output, for the next
// iteration through the loop
scheduler.resubmitFailedStages()
if (attempt < Stage.MAX_STAGE_FAILURES) {
...
```
(printlns left in there to help you follow along as you are running locally)
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]