-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-4014] Add TaskContext.attemptNumber and deprecate TaskContext.attemptId #3849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fd515a5
Add failing test for SPARK-4014
JoshRosen 1e7a933
[SPARK-4014] Change TaskContext.attemptId to return attempt number in…
JoshRosen 9d8d4d1
Doc typo
JoshRosen b2dffa3
Address some of Reynold's minor comments
JoshRosen cbe4d76
Preserve attemptId behavior and deprecate it:
JoshRosen 8c387ce
Use local with maxRetries instead of local-cluster.
JoshRosen 0b10526
Use putInt instead of putLong (silly mistake)
JoshRosen eee6a45
Merge remote-tracking branch 'origin/master' into SPARK-4014
JoshRosen 1d43aa6
Merge remote-tracking branch 'origin/master' into SPARK-4014
JoshRosen a180b88
Merge remote-tracking branch 'origin/master' into SPARK-4014
JoshRosen 38574d4
attemptId -> taskAttemptId in PairRDDFunctions
JoshRosen 5cfff05
Introduce wrapper for serializing Mesos task launch data.
JoshRosen 89d03e0
Merge remote-tracking branch 'origin/master' into SPARK-4014
JoshRosen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -45,13 +45,13 @@ class TaskContextSuite extends FunSuite with BeforeAndAfter with LocalSparkConte | |
| val task = new ResultTask[String, String]( | ||
| 0, sc.broadcast(closureSerializer.serialize((rdd, func)).array), rdd.partitions(0), Seq(), 0) | ||
| intercept[RuntimeException] { | ||
| task.run(0) | ||
| task.run(0, 0) | ||
| } | ||
| assert(TaskContextSuite.completed === true) | ||
| } | ||
|
|
||
| test("all TaskCompletionListeners should be called even if some fail") { | ||
| val context = new TaskContextImpl(0, 0, 0) | ||
| val context = new TaskContextImpl(0, 0, 0, 0) | ||
| val listener = mock(classOf[TaskCompletionListener]) | ||
| context.addTaskCompletionListener(_ => throw new Exception("blah")) | ||
| context.addTaskCompletionListener(listener) | ||
|
|
@@ -63,6 +63,33 @@ class TaskContextSuite extends FunSuite with BeforeAndAfter with LocalSparkConte | |
|
|
||
| verify(listener, times(1)).onTaskCompletion(any()) | ||
| } | ||
|
|
||
| test("TaskContext.attemptNumber should return attempt number, not task id (SPARK-4014)") { | ||
| sc = new SparkContext("local-cluster[2,1,512]", "test") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just realized that I can change the |
||
| // Check that attemptIds are 0 for all tasks' initial attempts | ||
| val attemptIds = sc.parallelize(Seq(1, 2), 2).mapPartitions { iter => | ||
| Seq(TaskContext.get().attemptNumber).iterator | ||
| }.collect() | ||
| assert(attemptIds.toSet === Set(0)) | ||
|
|
||
| // Test a job with failed tasks | ||
| val attemptIdsWithFailedTask = sc.parallelize(Seq(1, 2), 2).mapPartitions { iter => | ||
| val attemptId = TaskContext.get().attemptNumber | ||
| if (iter.next() == 1 && attemptId == 0) { | ||
| throw new Exception("First execution of task failed") | ||
| } | ||
| Seq(attemptId).iterator | ||
| }.collect() | ||
| assert(attemptIdsWithFailedTask.toSet === Set(0, 1)) | ||
| } | ||
|
|
||
| test("TaskContext.attemptId returns taskAttemptId for backwards-compatibility (SPARK-4014)") { | ||
| sc = new SparkContext("local-cluster[2,1,512]", "test") | ||
| val attemptIds = sc.parallelize(Seq(1, 2, 3, 4), 4).mapPartitions { iter => | ||
| Seq(TaskContext.get().attemptId).iterator | ||
| }.collect() | ||
| assert(attemptIds.toSet === Set(0, 1, 2, 3)) | ||
| } | ||
| } | ||
|
|
||
| private object TaskContextSuite { | ||
|
|
||
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we introduce another wrapper here instead? I'm imagine we will be adding more fields to serialize to Mesos executors, and it's a lot easier to maintain a struct then position with types and offsets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea; putting the serialization / deserialization code in the same wrapper class will make it much easier to verify that it's correct / test it separately. I'll push a new commit to do this.