[GitHub] spark pull request #16098: [SPARK-18672][CORE] Close recordwriter in SparkHa...
Github user asfgit closed the pull request at: https://github.com/apache/spark/pull/16098 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #16098: [SPARK-18672][CORE] Close recordwriter in SparkHa...
Github user HyukjinKwon commented on a diff in the pull request: https://github.com/apache/spark/pull/16098#discussion_r90679495 --- Diff: core/src/main/scala/org/apache/spark/internal/io/SparkHadoopMapReduceWriter.scala --- @@ -163,12 +164,20 @@ object SparkHadoopMapReduceWriter extends Logging { outputMetricsAndBytesWrittenCallback, recordsWritten) recordsWritten += 1 } - +writer.close(taskContext) --- End diff -- Doh! --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #16098: [SPARK-18672][CORE] Close recordwriter in SparkHa...
Github user srowen commented on a diff in the pull request: https://github.com/apache/spark/pull/16098#discussion_r90679120 --- Diff: core/src/main/scala/org/apache/spark/internal/io/SparkHadoopMapReduceWriter.scala --- @@ -163,12 +164,20 @@ object SparkHadoopMapReduceWriter extends Logging { outputMetricsAndBytesWrittenCallback, recordsWritten) recordsWritten += 1 } - +writer.close(taskContext) --- End diff -- Ah, but do you still want to null it here so that it doesn't also cause a close() in the catch block? the commit could fail. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #16098: [SPARK-18672][CORE] Close recordwriter in SparkHa...
Github user HyukjinKwon commented on a diff in the pull request: https://github.com/apache/spark/pull/16098#discussion_r90677329 --- Diff: core/src/main/scala/org/apache/spark/internal/io/SparkHadoopMapReduceWriter.scala --- @@ -163,12 +164,23 @@ object SparkHadoopMapReduceWriter extends Logging { outputMetricsAndBytesWrittenCallback, recordsWritten) recordsWritten += 1 } - +if (writer != null) { + writer.close(taskContext) + writer = null +} committer.commitTask(taskContext) }(catchBlock = { -committer.abortTask(taskContext) -logError(s"Task ${taskContext.getTaskAttemptID} aborted.") - }, finallyBlock = writer.close(taskContext)) +// If there is an error, release resource and then abort the task. +try { + if (writer != null) { --- End diff -- Oh yes. Thank you. Will address the comment above. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #16098: [SPARK-18672][CORE] Close recordwriter in SparkHa...
Github user srowen commented on a diff in the pull request: https://github.com/apache/spark/pull/16098#discussion_r90676226 --- Diff: core/src/main/scala/org/apache/spark/internal/io/SparkHadoopMapReduceWriter.scala --- @@ -163,12 +164,23 @@ object SparkHadoopMapReduceWriter extends Logging { outputMetricsAndBytesWrittenCallback, recordsWritten) recordsWritten += 1 } - +if (writer != null) { + writer.close(taskContext) + writer = null +} committer.commitTask(taskContext) }(catchBlock = { -committer.abortTask(taskContext) -logError(s"Task ${taskContext.getTaskAttemptID} aborted.") - }, finallyBlock = writer.close(taskContext)) +// If there is an error, release resource and then abort the task. +try { + if (writer != null) { --- End diff -- So this is also adding a defensive close before aborting, not just before committing? if that's important at all, OK. It didn't do that before. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #16098: [SPARK-18672][CORE] Close recordwriter in SparkHa...
Github user srowen commented on a diff in the pull request: https://github.com/apache/spark/pull/16098#discussion_r90676084 --- Diff: core/src/main/scala/org/apache/spark/internal/io/SparkHadoopMapReduceWriter.scala --- @@ -163,12 +164,23 @@ object SparkHadoopMapReduceWriter extends Logging { outputMetricsAndBytesWrittenCallback, recordsWritten) recordsWritten += 1 } - +if (writer != null) { --- End diff -- I don't think writer can be null here, but no big deal. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #16098: [SPARK-18672][CORE] Close recordwriter in SparkHa...
Github user HyukjinKwon commented on a diff in the pull request: https://github.com/apache/spark/pull/16098#discussion_r90660126 --- Diff: core/src/main/scala/org/apache/spark/internal/io/SparkHadoopMapReduceWriter.scala --- @@ -146,29 +146,32 @@ object SparkHadoopMapReduceWriter extends Logging { case c: Configurable => c.setConf(hadoopConf) case _ => () } -val writer = taskFormat.getRecordWriter(taskContext) - .asInstanceOf[RecordWriter[K, V]] -require(writer != null, "Unable to obtain RecordWriter") var recordsWritten = 0L // Write all rows in RDD partition. try { val ret = Utils.tryWithSafeFinallyAndFailureCallbacks { -while (iterator.hasNext) { - val pair = iterator.next() - writer.write(pair._1, pair._2) - - // Update bytes written metric every few records - SparkHadoopWriterUtils.maybeUpdateOutputMetrics( -outputMetricsAndBytesWrittenCallback, recordsWritten) - recordsWritten += 1 +val writer = taskFormat.getRecordWriter(taskContext) +require(writer != null, "Unable to obtain RecordWriter") --- End diff -- Ah, actually, I left a comment about this and then removed because I thought I might be too much worried. I at least checked `TextOutputFormat. getRecordWriter(..)` is able to create the attempt folder and `FileOutputCommitter.abortTask(..)` removes this. If this is located in the original place, it'd not remove the directory (although this case would be really rare). --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #16098: [SPARK-18672][CORE] Close recordwriter in SparkHa...
Github user HyukjinKwon commented on a diff in the pull request: https://github.com/apache/spark/pull/16098#discussion_r90643022 --- Diff: core/src/main/scala/org/apache/spark/internal/io/SparkHadoopMapReduceWriter.scala --- @@ -146,29 +146,32 @@ object SparkHadoopMapReduceWriter extends Logging { case c: Configurable => c.setConf(hadoopConf) case _ => () } -val writer = taskFormat.getRecordWriter(taskContext) - .asInstanceOf[RecordWriter[K, V]] -require(writer != null, "Unable to obtain RecordWriter") var recordsWritten = 0L // Write all rows in RDD partition. try { val ret = Utils.tryWithSafeFinallyAndFailureCallbacks { -while (iterator.hasNext) { - val pair = iterator.next() - writer.write(pair._1, pair._2) - - // Update bytes written metric every few records - SparkHadoopWriterUtils.maybeUpdateOutputMetrics( -outputMetricsAndBytesWrittenCallback, recordsWritten) - recordsWritten += 1 +val writer = taskFormat.getRecordWriter(taskContext) --- End diff -- I was a bit worried of moving this in here because we now abort the task when it fails to create a record reader. Just to convince myself, I at least checked `FileSystem.create(..)` is called within `TextOutputFormat.getRecordWriter` and it seems removed via `FileOutputCommitter.abortTask(..)`. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #16098: [SPARK-18672][CORE] Close recordwriter in SparkHa...
Github user HyukjinKwon commented on a diff in the pull request: https://github.com/apache/spark/pull/16098#discussion_r90634188 --- Diff: core/src/main/scala/org/apache/spark/internal/io/SparkHadoopMapReduceWriter.scala --- @@ -163,12 +163,22 @@ object SparkHadoopMapReduceWriter extends Logging { outputMetricsAndBytesWrittenCallback, recordsWritten) recordsWritten += 1 } - +if (writer != null) { + writer.close(taskContext) + writer = null +} committer.commitTask(taskContext) }(catchBlock = { -committer.abortTask(taskContext) -logError(s"Task ${taskContext.getTaskAttemptID} aborted.") - }, finallyBlock = writer.close(taskContext)) +try { + if (writer != null) { +writer.close(taskContext) +writer = null + } +} finally { + committer.abortTask(taskContext) + logError(s"Task ${taskContext.getTaskAttemptID} aborted.") +} + }) --- End diff -- I think I was worried of trivial and useless things. Let me try to follow this suggestion. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] spark pull request #16098: [SPARK-18672][CORE] Close recordwriter in SparkHa...
Github user srowen commented on a diff in the pull request: https://github.com/apache/spark/pull/16098#discussion_r90625904 --- Diff: core/src/main/scala/org/apache/spark/internal/io/SparkHadoopMapReduceWriter.scala --- @@ -163,12 +163,22 @@ object SparkHadoopMapReduceWriter extends Logging { outputMetricsAndBytesWrittenCallback, recordsWritten) recordsWritten += 1 } - +if (writer != null) { + writer.close(taskContext) + writer = null +} committer.commitTask(taskContext) }(catchBlock = { -committer.abortTask(taskContext) -logError(s"Task ${taskContext.getTaskAttemptID} aborted.") - }, finallyBlock = writer.close(taskContext)) +try { + if (writer != null) { +writer.close(taskContext) +writer = null + } +} finally { + committer.abortTask(taskContext) + logError(s"Task ${taskContext.getTaskAttemptID} aborted.") +} + }) --- End diff -- What about something like ``` val committer = ... try { ... val writer = ... try { ... } finally { writer.close() } committer.commitTask(...) } catch { ... commiter.abortTask(...) } ``` It's simpler but am I missing why it wouldn't work? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org