srowen commented on code in PR #50020:
URL: https://github.com/apache/spark/pull/50020#discussion_r1980625111
##########
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:
How does this handle interruption? it just re-sets the interrupt state of
the thread.
But does it even matter if this thread results in an exception due to
interruption? it's being cancelled.
Likewise why rewrap an Exception as SparkException, if that wasn't necessary
before?
--
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]