Copilot commented on code in PR #3829:
URL: https://github.com/apache/celeborn/pull/3829#discussion_r3877086917


##########
client/src/main/scala/org/apache/celeborn/client/ChangePartitionManager.scala:
##########
@@ -90,26 +90,38 @@ class ChangePartitionManager(
                 batchHandleChangePartitionExecutors.submit {
                   new Runnable {
                     override def run(): Unit = {
-                      val distinctPartitions = {
-                        val requestSet = inBatchPartitions.get(shuffleId)
-                        val locksForShuffle = locks.computeIfAbsent(shuffleId, 
locksRegisterFunc)
-                        requests.asScala.map { case (partitionId, request) =>
-                          locksForShuffle(partitionId % 
locksForShuffle.length).synchronized {
-                            if (!requestSet.contains(partitionId) && 
requests.containsKey(
-                                partitionId)) {
-                              requestSet.add(partitionId)
-                              Some(request.asScala.toArray.maxBy(_.epoch))
-                            } else {
-                              None
+                      try {
+                        val distinctPartitions = {
+                          val requestSet = inBatchPartitions.get(shuffleId)
+                          val locksForShuffle = 
locks.computeIfAbsent(shuffleId, locksRegisterFunc)
+                          requests.asScala.map { case (partitionId, request) =>
+                            locksForShuffle(partitionId % 
locksForShuffle.length).synchronized {
+                              if (!requestSet.contains(partitionId) && 
requests.containsKey(
+                                  partitionId)) {
+                                requestSet.add(partitionId)
+                                Some(request.asScala.toArray.maxBy(_.epoch))
+                              } else {
+                                None
+                              }
                             }
-                          }
-                        }.filter(_.isDefined).map(_.get).toArray
-                      }
-                      if (distinctPartitions.nonEmpty) {
-                        handleRequestPartitions(
-                          shuffleId,
-                          distinctPartitions,
-                          
lifecycleManager.commitManager.isSegmentGranularityVisible(shuffleId))
+                          }.filter(_.isDefined).map(_.get).toArray
+                        }
+                        if (distinctPartitions.nonEmpty) {
+                          handleRequestPartitions(
+                            shuffleId,
+                            distinctPartitions,
+                            
lifecycleManager.commitManager.isSegmentGranularityVisible(shuffleId))
+                        }
+                      } catch {
+                        case e: InterruptedException =>
+                          logError(
+                            s"Batch handle change partition for shuffle 
$shuffleId interrupted.",
+                            e)
+                          throw e

Review Comment:
   This catch rethrows `InterruptedException`, but the interrupt status is 
cleared when the exception is thrown. Re-interrupting the thread before rethrow 
helps preserve cancellation/shutdown semantics for executor threads (see 
similar handling in `ApplicationHeartbeater.scala`).



##########
client/src/main/java/org/apache/celeborn/client/read/DfsPartitionReader.java:
##########
@@ -283,10 +284,16 @@ public ByteBuf next() throws Exception {
                 results.put(Pair.of(currentChunkIndex, 
Unpooled.wrappedBuffer(buffer)));
                 logger.debug("add index {} to results", currentChunkIndex++);
               }
-            } catch (Exception e) {
-              logger.warn("Fetch thread is cancelled.", e);
-              exception.set(e);
+            } catch (InterruptedException e) {
               // cancel a task for speculative, ignore this exception
+              logger.warn("Read thread is interrupted.", e);
+            } catch (Throwable t) {

Review Comment:
   The DFS fetch background thread now swallows InterruptedException without 
setting `exception`. If `close()` (or shutdownNow) interrupts the fetch thread 
while another thread is blocked in `next()`, the fetch thread exits and 
`next()` can wait indefinitely because `checkException()` never trips and no 
more results will be produced.



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

Reply via email to