aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/scala/org
diff options
context:
space:
mode:
authorjinxing <jinxing@meituan.com>2017-01-18 10:47:22 -0800
committerMarcelo Vanzin <vanzin@cloudera.com>2017-01-18 10:47:22 -0800
commit33791a8ced61d1ffa09f68033d240f874fdb1593 (patch)
tree8183db0788184cdb66d62d81956f77cb62827d7e /core/src/test/scala/org
parent278fa1eb305220a85c816c948932d6af8fa619aa (diff)
downloadspark-33791a8ced61d1ffa09f68033d240f874fdb1593.tar.gz
spark-33791a8ced61d1ffa09f68033d240f874fdb1593.tar.bz2
spark-33791a8ced61d1ffa09f68033d240f874fdb1593.zip
[SPARK-18113] Use ask to replace askWithRetry in canCommit and make receiver idempotent.
## What changes were proposed in this pull request? Method canCommit sends AskPermissionToCommitOutput using askWithRetry. If timeout, it will send again. Thus AskPermissionToCommitOutput can be received multi times. Method canCommit should return the same value when called by the same attempt multi times. In implementation before this fix, method handleAskPermissionToCommit just check if there is committer already registered, which is not enough. When worker retries AskPermissionToCommitOutput it will get CommitDeniedException, then the task will fail with reason TaskCommitDenied, which is not regarded as a task failure(SPARK-11178), so TaskScheduler will schedule this task infinitely. In this fix, use `ask` to replace `askWithRetry` in `canCommit` and make receiver idempotent. ## How was this patch tested? Added a new unit test to OutputCommitCoordinatorSuite. Author: jinxing <jinxing@meituan.com> Closes #16503 from jinxing64/SPARK-18113.
Diffstat (limited to 'core/src/test/scala/org')
-rw-r--r--core/src/test/scala/org/apache/spark/scheduler/OutputCommitCoordinatorSuite.scala16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/src/test/scala/org/apache/spark/scheduler/OutputCommitCoordinatorSuite.scala b/core/src/test/scala/org/apache/spark/scheduler/OutputCommitCoordinatorSuite.scala
index 8c4e389e86..0c362b881d 100644
--- a/core/src/test/scala/org/apache/spark/scheduler/OutputCommitCoordinatorSuite.scala
+++ b/core/src/test/scala/org/apache/spark/scheduler/OutputCommitCoordinatorSuite.scala
@@ -189,6 +189,12 @@ class OutputCommitCoordinatorSuite extends SparkFunSuite with BeforeAndAfter {
assert(
!outputCommitCoordinator.canCommit(stage, partition, nonAuthorizedCommitter + 3))
}
+
+ test("Duplicate calls to canCommit from the authorized committer gets idempotent responses.") {
+ val rdd = sc.parallelize(Seq(1), 1)
+ sc.runJob(rdd, OutputCommitFunctions(tempDir.getAbsolutePath).callCanCommitMultipleTimes _,
+ 0 until rdd.partitions.size)
+ }
}
/**
@@ -221,6 +227,16 @@ private case class OutputCommitFunctions(tempDirPath: String) {
if (ctx.attemptNumber == 0) failingOutputCommitter else successfulOutputCommitter)
}
+ // Receiver should be idempotent for AskPermissionToCommitOutput
+ def callCanCommitMultipleTimes(iter: Iterator[Int]): Unit = {
+ val ctx = TaskContext.get()
+ val canCommit1 = SparkEnv.get.outputCommitCoordinator
+ .canCommit(ctx.stageId(), ctx.partitionId(), ctx.attemptNumber())
+ val canCommit2 = SparkEnv.get.outputCommitCoordinator
+ .canCommit(ctx.stageId(), ctx.partitionId(), ctx.attemptNumber())
+ assert(canCommit1 && canCommit2)
+ }
+
private def runCommitWithProvidedCommitter(
ctx: TaskContext,
iter: Iterator[Int],