jjayadeep06 commented on code in PR #50020:
URL: https://github.com/apache/spark/pull/50020#discussion_r1980639195


##########
core/src/main/scala/org/apache/spark/BarrierCoordinator.scala:
##########
@@ -119,26 +121,43 @@ private[spark] class BarrierCoordinator(
     // A timer task that ensures we may timeout for a barrier() call.
     private var timerTask: TimerTask = null
 
-    // Init a TimerTask for a barrier() call.
+    /* Init a TimerTask for a barrier() call and also add logic to handle 
Thread Interruption 
+    * which is invoked when the timerTask.cancel(true) is invokved.
+    */
     private def initTimerTask(state: ContextBarrierState): Unit = {
       timerTask = new TimerTask {
-        override def run(): Unit = state.synchronized {
-          // Timeout current barrier() call, fail all the sync requests.
-          requesters.foreach(_.sendFailure(new SparkException("The coordinator 
didn't get all " +
-            s"barrier sync requests for barrier epoch $barrierEpoch from 
$barrierId within " +
-            s"$timeoutInSecs second(s).")))
-          cleanupBarrierStage(barrierId)
-        }
+        override def run(): Unit =
+          try {
+            state.synchronized {
+              if (!Thread.currentThread().isInterrupted()) {
+                // Timeout current barrier() call, fail all the sync requests.
+                requesters.foreach(
+                  _.sendFailure(new SparkException("The coordinator didn't get 
all " +
+                    s"barrier sync requests for barrier epoch +" +
+                    s" $barrierEpoch from $barrierId within " +
+                    s"$timeoutInSecs second(s).")))
+              }
+            }
+          } catch {
+            case _: InterruptedException =>
+              // Handle interruption gracefully

Review Comment:
   It does not matter, I had introduced this logic to ensure that cancellation 
only via thread interruption is handled, for rest of the cases if any an error 
message is logged. I think I will remove it as this distinction might not be 
relevant.



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