This is an automated email from the ASF dual-hosted git repository.

zhouky pushed a commit to branch branch-0.3
in repository https://gitbox.apache.org/repos/asf/incubator-celeborn.git


The following commit(s) were added to refs/heads/branch-0.3 by this push:
     new 369e50793 [CELEBORN-1099] Check register when handleGetReducerFileGroup
369e50793 is described below

commit 369e507938e47af4305ac5b504b87d4a3ddc1318
Author: onebox-li <[email protected]>
AuthorDate: Tue Oct 31 21:25:55 2023 +0800

    [CELEBORN-1099] Check register when handleGetReducerFileGroup
    
    ### What changes were proposed in this pull request?
    For spark case, when stage outputPartitioning is satisfied and no longer 
needs shuffle exchange, there will be no shuffle write procedure, same goes for 
`RegisterShuffle`, currently the origin reduce stage will throw a NPE when 
LifeCycleManager `handleGetReducerFileGroup`.
    ```
    ERROR [dispatcher-event-loop-11] Inbox: Ignoring error
    java.lang.NullPointerException: null
        at 
org.apache.celeborn.client.commit.ReducePartitionCommitHandler.handleGetReducerFileGroup(ReducePartitionCommitHandler.scala:307)
        at 
org.apache.celeborn.client.CommitManager.handleGetReducerFileGroup(CommitManager.scala:266)
        at 
org.apache.celeborn.client.LifecycleManager.org$apache$celeborn$client$LifecycleManager$$handleGetReducerFileGroup(LifecycleManager.scala:556)
        at 
org.apache.celeborn.client.LifecycleManager$$anonfun$receiveAndReply$1.applyOrElse(LifecycleManager.scala:298)
        at 
org.apache.celeborn.common.rpc.netty.Inbox.$anonfun$process$1(Inbox.scala:115)
        at 
org.apache.celeborn.common.rpc.netty.Inbox.safelyCall(Inbox.scala:222)
        at org.apache.celeborn.common.rpc.netty.Inbox.process(Inbox.scala:110)
        at 
org.apache.celeborn.common.rpc.netty.Dispatcher$MessageLoop.run(Dispatcher.scala:227)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
    ```
    Reproduce example like:
    `select count(*) as cnt from tableA;`
    And tableA is empty.
    
    So here fix code to adapt to this normal situation. For Flink client, just 
follows the old behavior.
    
    ### Why are the changes needed?
    Fix the probable NPE.
    
    ### Does this PR introduce _any_ user-facing change?
    No.
    
    ### How was this patch tested?
    Cluster test.
    
    Closes #2056 from onebox-li/fix-empty-shuffle-npe.
    
    Authored-by: onebox-li <[email protected]>
    Signed-off-by: zky.zhoukeyong <[email protected]>
    (cherry picked from commit f6cc377c1515c09b4edaf4bdfa5812e5f02f3d35)
    Signed-off-by: zky.zhoukeyong <[email protected]>
---
 .../apache/celeborn/client/ShuffleClientImpl.java  | 40 ++++++++++----------
 .../org/apache/celeborn/client/CommitManager.scala | 44 ++++++++++------------
 .../apache/celeborn/client/LifecycleManager.scala  | 11 +++++-
 3 files changed, 49 insertions(+), 46 deletions(-)

diff --git 
a/client/src/main/java/org/apache/celeborn/client/ShuffleClientImpl.java 
b/client/src/main/java/org/apache/celeborn/client/ShuffleClientImpl.java
index a2500dfaf..85379a535 100644
--- a/client/src/main/java/org/apache/celeborn/client/ShuffleClientImpl.java
+++ b/client/src/main/java/org/apache/celeborn/client/ShuffleClientImpl.java
@@ -1550,26 +1550,26 @@ public class ShuffleClientImpl extends ShuffleClient {
                 conf.clientRpcGetReducerFileGroupRpcAskTimeout(),
                 ClassTag$.MODULE$.apply(GetReducerFileGroupResponse.class));
 
-        if (response.status() == StatusCode.SUCCESS) {
-          logger.info(
-              "Shuffle {} request reducer file group success using {} ms, 
result partition size {}.",
-              shuffleId,
-              TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - 
getReducerFileGroupStartTime),
-              response.fileGroup().size());
-          return new ReduceFileGroups(
-              response.fileGroup(), response.attempts(), 
response.partitionIds());
-        } else if (response.status() == StatusCode.STAGE_END_TIME_OUT) {
-          logger.warn(
-              "Request {} return {} for {}.",
-              getReducerFileGroup,
-              StatusCode.STAGE_END_TIME_OUT,
-              shuffleId);
-        } else if (response.status() == StatusCode.SHUFFLE_DATA_LOST) {
-          logger.warn(
-              "Request {} return {} for {}.",
-              getReducerFileGroup,
-              StatusCode.SHUFFLE_DATA_LOST,
-              shuffleId);
+        switch (response.status()) {
+          case SUCCESS:
+            logger.info(
+                "Shuffle {} request reducer file group success using {} ms, 
result partition size {}.",
+                shuffleId,
+                TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - 
getReducerFileGroupStartTime),
+                response.fileGroup().size());
+            return new ReduceFileGroups(
+                response.fileGroup(), response.attempts(), 
response.partitionIds());
+          case STAGE_END_TIME_OUT:
+          case SHUFFLE_DATA_LOST:
+            logger.warn(
+                "Request {} return {} for {}.", getReducerFileGroup, 
response.status(), shuffleId);
+            return null;
+          case SHUFFLE_NOT_REGISTERED:
+            logger.warn(
+                "Request {} return {} for {}.", getReducerFileGroup, 
response.status(), shuffleId);
+            // return empty result
+            return new ReduceFileGroups(
+                response.fileGroup(), response.attempts(), 
response.partitionIds());
         }
       } catch (Exception e) {
         logger.error("Exception raised while call GetReducerFileGroup for 
{}.", shuffleId, e);
diff --git 
a/client/src/main/scala/org/apache/celeborn/client/CommitManager.scala 
b/client/src/main/scala/org/apache/celeborn/client/CommitManager.scala
index e7a81aa61..beea26e20 100644
--- a/client/src/main/scala/org/apache/celeborn/client/CommitManager.scala
+++ b/client/src/main/scala/org/apache/celeborn/client/CommitManager.scala
@@ -268,30 +268,26 @@ class CommitManager(appUniqueId: String, val conf: 
CelebornConf, lifecycleManage
 
   private def getCommitHandler(shuffleId: Int): CommitHandler = {
     val partitionType = lifecycleManager.getPartitionType(shuffleId)
-    if (commitHandlers.containsKey(partitionType)) {
-      commitHandlers.get(partitionType)
-    } else {
-      commitHandlers.computeIfAbsent(
-        partitionType,
-        (partitionType: PartitionType) => {
-          partitionType match {
-            case PartitionType.REDUCE => new ReducePartitionCommitHandler(
-                appUniqueId,
-                conf,
-                lifecycleManager.shuffleAllocatedWorkers,
-                committedPartitionInfo,
-                lifecycleManager.workerStatusTracker)
-            case PartitionType.MAP => new MapPartitionCommitHandler(
-                appUniqueId,
-                conf,
-                lifecycleManager.shuffleAllocatedWorkers,
-                committedPartitionInfo,
-                lifecycleManager.workerStatusTracker)
-            case _ => throw new UnsupportedOperationException(
-                s"Unexpected ShufflePartitionType for CommitManager: 
$partitionType")
-          }
-        })
-    }
+    commitHandlers.computeIfAbsent(
+      partitionType,
+      (partitionType: PartitionType) => {
+        partitionType match {
+          case PartitionType.REDUCE => new ReducePartitionCommitHandler(
+              appUniqueId,
+              conf,
+              lifecycleManager.shuffleAllocatedWorkers,
+              committedPartitionInfo,
+              lifecycleManager.workerStatusTracker)
+          case PartitionType.MAP => new MapPartitionCommitHandler(
+              appUniqueId,
+              conf,
+              lifecycleManager.shuffleAllocatedWorkers,
+              committedPartitionInfo,
+              lifecycleManager.workerStatusTracker)
+          case _ => throw new UnsupportedOperationException(
+              s"Unexpected ShufflePartitionType for CommitManager: 
$partitionType")
+        }
+      })
   }
 
   def commitMetrics(): (Long, Long) = 
commitHandlers.asScala.values.foldLeft(0L -> 0L) {
diff --git 
a/client/src/main/scala/org/apache/celeborn/client/LifecycleManager.scala 
b/client/src/main/scala/org/apache/celeborn/client/LifecycleManager.scala
index bd8527db3..515269896 100644
--- a/client/src/main/scala/org/apache/celeborn/client/LifecycleManager.scala
+++ b/client/src/main/scala/org/apache/celeborn/client/LifecycleManager.scala
@@ -293,8 +293,7 @@ class LifecycleManager(val appUniqueId: String, val conf: 
CelebornConf) extends
       }
 
     case GetReducerFileGroup(shuffleId: Int) =>
-      logDebug(s"Received GetShuffleFileGroup request," +
-        s"shuffleId $shuffleId.")
+      logDebug(s"Received GetShuffleFileGroup request for shuffleId 
$shuffleId.")
       handleGetReducerFileGroup(context, shuffleId)
   }
 
@@ -553,6 +552,14 @@ class LifecycleManager(val appUniqueId: String, val conf: 
CelebornConf) extends
   private def handleGetReducerFileGroup(
       context: RpcCallContext,
       shuffleId: Int): Unit = {
+    if (!registeredShuffle.contains(shuffleId)) {
+      logWarning(s"[handleGetReducerFileGroup] shuffle $shuffleId not 
registered, maybe no shuffle data within this stage.")
+      context.reply(GetReducerFileGroupResponse(
+        StatusCode.SHUFFLE_NOT_REGISTERED,
+        JavaUtils.newConcurrentHashMap(),
+        Array.empty))
+      return
+    }
     commitManager.handleGetReducerFileGroup(context, shuffleId)
   }
 

Reply via email to