dongjoon-hyun commented on code in PR #54280:
URL: https://github.com/apache/spark/pull/54280#discussion_r2796788269


##########
core/src/main/scala/org/apache/spark/deploy/history/EventLogFileWriters.scala:
##########
@@ -131,7 +131,20 @@ abstract class EventLogFileWriter(
   }
 
   protected def closeWriter(): Unit = {
+    // 1. Flush first to check the errors
+    writer.foreach(_.flush())
+    if (writer.exists(_.checkError())) {
+      logWarning("Spark detects errors while flushing event logs.")
+    }
+    hadoopDataStream.foreach(_.hflush())
+
+    // 2. Try to close and check the errors
     writer.foreach(_.close())
+    if (writer.exists(_.checkError())) {
+      logWarning("Spark detects errors while closing event logs.")
+    }
+    // 3. Ensuring the underlying stream is closed at least (best-effort).
+    hadoopDataStream.foreach(_.close())

Review Comment:
   Yes, that's correct, @pan3793 . However, we have multiple layers from 
`PrintWriter`  to `Hadoop (and S3AFileSystem)` layer. We found that there is a 
situation of missing event log file (the last file). This PR has no harm in a 
normal case . We only double-checking `checkError` according to the Java 
guidelines and make it sure by double-closing. AFAIK, `FSDataOutputStream` is 
designed to be idempotent.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to