-
Notifications
You must be signed in to change notification settings - Fork 28.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-10381] Fix mixup of taskAttemptNumber & attemptId in OutputCom…
…mitCoordinator When speculative execution is enabled, consider a scenario where the authorized committer of a particular output partition fails during the OutputCommitter.commitTask() call. In this case, the OutputCommitCoordinator is supposed to release that committer's exclusive lock on committing once that task fails. However, due to a unit mismatch (we used task attempt number in one place and task attempt id in another) the lock will not be released, causing Spark to go into an infinite retry loop. This bug was masked by the fact that the OutputCommitCoordinator does not have enough end-to-end tests (the current tests use many mocks). Other factors contributing to this bug are the fact that we have many similarly-named identifiers that have different semantics but the same data types (e.g. attemptNumber and taskAttemptId, with inconsistent variable naming which makes them difficult to distinguish). This patch adds a regression test and fixes this bug by always using task attempt numbers throughout this code. Author: Josh Rosen <[email protected]> Closes #8544 from JoshRosen/SPARK-10381. (cherry picked from commit 38700ea) Signed-off-by: Josh Rosen <[email protected]>
- Loading branch information
Showing
17 changed files
with
157 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
core/src/test/scala/org/apache/spark/scheduler/OutputCommitCoordinatorIntegrationSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.scheduler | ||
|
||
import org.apache.hadoop.mapred.{FileOutputCommitter, TaskAttemptContext} | ||
import org.scalatest.concurrent.Timeouts | ||
import org.scalatest.time.{Span, Seconds} | ||
|
||
import org.apache.spark.{SparkConf, SparkContext, LocalSparkContext, SparkFunSuite, TaskContext} | ||
import org.apache.spark.util.Utils | ||
|
||
/** | ||
* Integration tests for the OutputCommitCoordinator. | ||
* | ||
* See also: [[OutputCommitCoordinatorSuite]] for unit tests that use mocks. | ||
*/ | ||
class OutputCommitCoordinatorIntegrationSuite | ||
extends SparkFunSuite | ||
with LocalSparkContext | ||
with Timeouts { | ||
|
||
override def beforeAll(): Unit = { | ||
super.beforeAll() | ||
val conf = new SparkConf() | ||
.set("master", "local[2,4]") | ||
.set("spark.speculation", "true") | ||
.set("spark.hadoop.mapred.output.committer.class", | ||
classOf[ThrowExceptionOnFirstAttemptOutputCommitter].getCanonicalName) | ||
sc = new SparkContext("local[2, 4]", "test", conf) | ||
} | ||
|
||
test("exception thrown in OutputCommitter.commitTask()") { | ||
// Regression test for SPARK-10381 | ||
failAfter(Span(60, Seconds)) { | ||
val tempDir = Utils.createTempDir() | ||
try { | ||
sc.parallelize(1 to 4, 2).map(_.toString).saveAsTextFile(tempDir.getAbsolutePath + "/out") | ||
} finally { | ||
Utils.deleteRecursively(tempDir) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private class ThrowExceptionOnFirstAttemptOutputCommitter extends FileOutputCommitter { | ||
override def commitTask(context: TaskAttemptContext): Unit = { | ||
val ctx = TaskContext.get() | ||
if (ctx.attemptNumber < 1) { | ||
throw new java.io.FileNotFoundException("Intentional exception") | ||
} | ||
super.commitTask(context) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.