-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
[SPARK-41448] Make consistent MR job IDs in FileBatchWriter and FileFormatWriter #38980
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,14 +201,14 @@ object FileFormatWriter extends Logging { | |
rdd | ||
} | ||
|
||
val jobIdInstant = new Date().getTime | ||
val jobTrackerID = SparkHadoopWriterUtils.createJobTrackerID(new Date()) | ||
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. i must have missed this -but also we've not had any reports of the timstamp clash surfacing. that's probably because the s3a and abfs/gcs committers all pick up the uuid in "spark.sql.sources.writeJobUUID" in preference to anything else, and they are being generated uniquely |
||
val ret = new Array[WriteTaskResult](rddWithNonEmptyPartitions.partitions.length) | ||
sparkSession.sparkContext.runJob( | ||
rddWithNonEmptyPartitions, | ||
(taskContext: TaskContext, iter: Iterator[InternalRow]) => { | ||
executeTask( | ||
description = description, | ||
jobIdInstant = jobIdInstant, | ||
jobTrackerID = jobTrackerID, | ||
sparkStageId = taskContext.stageId(), | ||
sparkPartitionId = taskContext.partitionId(), | ||
sparkAttemptNumber = taskContext.taskAttemptId().toInt & Integer.MAX_VALUE, | ||
|
@@ -244,15 +244,15 @@ object FileFormatWriter extends Logging { | |
/** Writes data out in a single Spark task. */ | ||
private def executeTask( | ||
description: WriteJobDescription, | ||
jobIdInstant: Long, | ||
jobTrackerID: String, | ||
sparkStageId: Int, | ||
sparkPartitionId: Int, | ||
sparkAttemptNumber: Int, | ||
committer: FileCommitProtocol, | ||
iterator: Iterator[InternalRow], | ||
concurrentOutputWriterSpec: Option[ConcurrentOutputWriterSpec]): WriteTaskResult = { | ||
|
||
val jobId = SparkHadoopWriterUtils.createJobID(new Date(jobIdInstant), sparkStageId) | ||
val jobId = SparkHadoopWriterUtils.createJobID(jobTrackerID, sparkStageId) | ||
val taskId = new TaskID(jobId, TaskType.MAP, sparkPartitionId) | ||
val taskAttemptId = new TaskAttemptID(taskId, sparkAttemptNumber) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,9 @@ import org.apache.spark.sql.execution.datasources.{DynamicPartitionDataSingleWri | |
case class FileWriterFactory ( | ||
description: WriteJobDescription, | ||
committer: FileCommitProtocol) extends DataWriterFactory { | ||
|
||
private val jobId = SparkHadoopWriterUtils.createJobID(new Date, 0) | ||
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. @boneanxs It looks like tha 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. it does implement WritableComparable; you could use WritableConverter to do the marshalling if you don't just want to do via a string |
||
|
||
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. I wonder if a uuid should be created here which is then passed down in that "spark.sql.sources.writeJobUUID" option in |
||
override def createWriter(partitionId: Int, realTaskId: Long): DataWriter[InternalRow] = { | ||
val taskAttemptContext = createTaskAttemptContext(partitionId) | ||
committer.setupTask(taskAttemptContext) | ||
|
@@ -40,7 +43,6 @@ case class FileWriterFactory ( | |
} | ||
|
||
private def createTaskAttemptContext(partitionId: Int): TaskAttemptContextImpl = { | ||
val jobId = SparkHadoopWriterUtils.createJobID(new Date, 0) | ||
val taskId = new TaskID(jobId, TaskType.MAP, partitionId) | ||
val taskAttemptId = new TaskAttemptID(taskId, 0) | ||
// Set up the configuration object | ||
|
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.
how about extending the comment here by noting that the job id needs to be unique across all jobs (linking to SPARK-33402) and consistently across places used (SPARK-26873 + SPARK-41448). That way, whoever next goes near the code knows what is needed