Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add regression test
  • Loading branch information
JoshRosen committed Jul 22, 2015
commit 448eae83c190789e1946f010eecb36ee49d99e4f
25 changes: 25 additions & 0 deletions core/src/test/scala/org/apache/spark/FailureSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,30 @@ class FailureSuite extends SparkFunSuite with LocalSparkContext {
FailureSuiteState.clear()
}

test("managed memory leak error should not mask other failures (SPARK-9266") {
val conf = new SparkConf().set("spark.unsafe.exceptionOnMemoryLeak", "true")
sc = new SparkContext("local[1,1]", "test", conf)

// If a task leaks memory but fails due to some other cause, then make sure that the original
// cause is preserved
val thrownDueToTaskFailure = intercept[SparkException] {
sc.parallelize(Seq(0)).mapPartitions { iter =>
TaskContext.get().taskMemoryManager().allocate(128)
throw new Exception("intentional task failure")
iter
}.count()
}
assert(thrownDueToTaskFailure.getMessage.contains("intentional task failure"))

// If the task succeeded but memory was leaked, then the task should fail due to that leak
val thrownDueToMemoryLeak = intercept[SparkException] {
sc.parallelize(Seq(0)).mapPartitions { iter =>
TaskContext.get().taskMemoryManager().allocate(128)
iter
}.count()
}
assert(thrownDueToMemoryLeak.getMessage.contains("memory leak"))
}

// TODO: Need to add tests with shuffle fetch failures.
}