mridulm commented on code in PR #53540:
URL: https://github.com/apache/spark/pull/53540#discussion_r2662267717


##########
core/src/main/scala/org/apache/spark/util/ShutdownHookManager.scala:
##########
@@ -223,11 +230,26 @@ private [util] class SparkShutdownHookManager {
 
 }
 
-private class SparkShutdownHook(private val priority: Int, hook: () => Unit)
-  extends Comparable[SparkShutdownHook] {
+private class SparkShutdownHook(
+    private val priority: Int,
+    private val name: String,
+    hook: () => Unit,
+    clock: Clock = new SystemClock())
+  extends Comparable[SparkShutdownHook] with Logging {
 
   override def compareTo(other: SparkShutdownHook): Int = 
other.priority.compareTo(priority)
 
-  def run(): Unit = hook()
-
+  def run(): Unit = {
+    val startTime = clock.getTimeMillis()
+    try {
+      hook()
+      logInfo(s"Shutdown hook completed: $name (priority=$priority, " +
+        s"time=${clock.getTimeMillis() - startTime}ms)")
+    } catch {
+      case e: Throwable =>
+        logError(s"Shutdown hook failed: $name (priority=$priority, " +
+          s"time=${clock.getTimeMillis() - startTime}ms)", e)
+        throw e
+    }
+  }

Review Comment:
   +CC @sryza you had made changes to suppress logging from shutdown hook 
recently.
   PTAL at this PR.



-- 
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