-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-33402][CORE] Jobs launched in same second have duplicate MapReduce JobIDs #30319
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
steveloughran
wants to merge
3
commits into
apache:master
from
steveloughran:BUG/SPARK-33402-jobuuid
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
5dd9984
[SPARK-33402][CORE] SparkHadoopWriter to set unique job ID in "spark.…
steveloughran 72331d7
[SPARK-33402][CORE] Jobs launched in same second have duplicate JobIDs
steveloughran 1150360
[SPARK-33402] use date as prefix, single random long adds 2^63 bits of
steveloughran 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
102 changes: 102 additions & 0 deletions
102
core/src/test/scala/org/apache/spark/internal/io/SparkHadoopWriterUtilsSuite.scala
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 |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /* | ||
| * 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.internal.io | ||
|
|
||
| import java.util.Date | ||
|
|
||
| import org.apache.hadoop.mapreduce.JobID | ||
|
|
||
| import org.apache.spark.SparkFunSuite | ||
| import org.apache.spark.internal.io.SparkHadoopWriterUtils.createJobID | ||
|
|
||
| /** | ||
| * Unit tests for functions in SparkHadoopWriterUtils. | ||
| */ | ||
| class SparkHadoopWriterUtilsSuite extends SparkFunSuite { | ||
|
|
||
| /** | ||
| * Core test of JobID generation: | ||
| * They are created. | ||
| * The job number is converted to the job ID. | ||
| * They round trip to string and back | ||
| * (which implies that the full string matches the regexp | ||
| * in the JobID class). | ||
| */ | ||
| test("JobID Generation") { | ||
| val jobNumber = 1010 | ||
| val j1 = createJobID(new Date(), jobNumber) | ||
| assert(jobNumber == j1.getId, | ||
| s"Job number mismatch in $j1") | ||
|
|
||
| val jobStr = j1.toString | ||
| // the string value begins with job_ | ||
| assert(jobStr.startsWith("job_"), | ||
| s"wrong prefix of $jobStr") | ||
| // and the hadoop code can parse it | ||
| val j2 = roundTrip(j1) | ||
| assert(j1.getId == j2.getId, "Job ID mismatch") | ||
| assert(j1.getJtIdentifier == j2.getJtIdentifier, "Job identifier mismatch") | ||
| } | ||
|
|
||
| /** | ||
| * This is the problem surfacing in situations where committers expect | ||
| * Job IDs to be unique: if the timestamp is (exclusively) used | ||
| * then there will conflict in directories created. | ||
| */ | ||
| test("JobIDs generated at same time are different") { | ||
| val now = new Date() | ||
| val j1 = createJobID(now, 1) | ||
| val j2 = createJobID(now, 1) | ||
| assert(j1.toString != j2.toString) | ||
| } | ||
|
|
||
| /** | ||
| * There's nothing explicitly in the Hadoop classes to stop | ||
| * job numbers being negative. | ||
| * There's some big assumptions in the FileOutputCommitter about attempt IDs | ||
| * being positive during any recovery operations; for safety the ID | ||
| * job number is validated. | ||
| */ | ||
| test("JobIDs with negative job number") { | ||
| intercept[IllegalArgumentException] { | ||
| createJobID(new Date(), -1) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * If someone ever does reinstate use of timestamps, | ||
| * make sure that the case of timestamp == 0 is handled. | ||
| */ | ||
| test("JobIDs on Epoch are different") { | ||
| val j1 = createJobID(new Date(0), 0) | ||
| val j2 = createJobID(new Date(0), 0) | ||
| assert (j1.toString != j2.toString) | ||
| } | ||
|
|
||
| /** | ||
| * Do a round trip as a string and back again. | ||
| * This uses the JobID parser. | ||
| * @param jobID job ID | ||
| * @return the returned jobID | ||
| */ | ||
| private def roundTrip(jobID: JobID): JobID = { | ||
| val parsedJobId = JobID.forName(jobID.toString) | ||
| assert(jobID == parsedJobId, "Round trip was inconsistent") | ||
| parsedJobId | ||
| } | ||
| } |
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.
I'm wondering why is this needed. Can't commit protocol just get a unique job ID from the constructor parameters?
https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/internal/io/FileCommitProtocol.scala#L32-L34