RexXiong commented on code in PR #3059:
URL: https://github.com/apache/celeborn/pull/3059#discussion_r1914334863


##########
worker/src/main/scala/org/apache/celeborn/service/deploy/worker/Controller.scala:
##########
@@ -52,32 +52,46 @@ private[deploy] class Controller(
   var shuffleMapperAttempts: ConcurrentHashMap[String, AtomicIntegerArray] = _
   // shuffleKey -> (epoch -> CommitInfo)
   var shuffleCommitInfos: ConcurrentHashMap[String, ConcurrentHashMap[Long, 
CommitInfo]] = _
+  var shuffleCommitTime: ConcurrentHashMap[String, ConcurrentHashMap[Long, 
(Int, RpcCallContext)]] =

Review Comment:
   pls add description for shuffleCommitTime



##########
worker/src/main/scala/org/apache/celeborn/service/deploy/worker/Controller.scala:
##########
@@ -439,12 +446,13 @@ private[deploy] class Controller(
         return
       } else if (commitInfo.status == CommitInfo.COMMIT_INPROCESS) {
         logInfo(s"$shuffleKey CommitFiles inprogress, wait for finish")
-        // should not use commitThreadPool in case of block by commit files.
-        waitThreadPool.submit(new Runnable {
-          override def run(): Unit = {
-            waitForCommitFinish()
-          }
-        })
+        // Replace the ThreadPool to avoid blocking
+        // Read and write security of epoch in epochWaitTimeMap is guaranteed 
by commitInfo's lock
+        shuffleCommitTime.putIfAbsent(
+          shuffleKey,
+          JavaUtils.newConcurrentHashMap[Long, (Int, RpcCallContext)]())
+        val epochWaitTimeMap = shuffleCommitTime.get(shuffleKey)
+        epochWaitTimeMap.putIfAbsent(epoch, (0, context))

Review Comment:
   Maybe there is already a context here.



##########
worker/src/main/scala/org/apache/celeborn/service/deploy/worker/Controller.scala:
##########
@@ -730,6 +738,41 @@ private[deploy] class Controller(
     }
   }
 
+  def checkCommitTimeout(shuffleCommitTime: ConcurrentHashMap[
+    String,
+    ConcurrentHashMap[Long, (Int, RpcCallContext)]]): Unit = {
+    val delta = 100
+
+    shuffleCommitTime.asScala.foreach {
+      case (shuffleKey, epochWaitTimeMap) =>
+        epochWaitTimeMap.asScala.foreach { case (epoch, (waitTime, context)) =>
+          val commitInfo = shuffleCommitInfos.get(shuffleKey).get(epoch)

Review Comment:
   should check shuffleCommitInfos.get(shuffleKey) is null or not



##########
worker/src/main/scala/org/apache/celeborn/service/deploy/worker/Controller.scala:
##########
@@ -730,6 +738,41 @@ private[deploy] class Controller(
     }
   }
 
+  def checkCommitTimeout(shuffleCommitTime: ConcurrentHashMap[
+    String,
+    ConcurrentHashMap[Long, (Int, RpcCallContext)]]): Unit = {
+    val delta = 100
+
+    shuffleCommitTime.asScala.foreach {
+      case (shuffleKey, epochWaitTimeMap) =>
+        epochWaitTimeMap.asScala.foreach { case (epoch, (waitTime, context)) =>
+          val commitInfo = shuffleCommitInfos.get(shuffleKey).get(epoch)
+          commitInfo.synchronized {
+            if (commitInfo.status == CommitInfo.COMMIT_FINISHED) {
+              context.reply(commitInfo.response)
+              epochWaitTimeMap.remove(epoch)
+            } else {
+              if (waitTime * delta < shuffleCommitTimeout) {
+                shuffleCommitTime.get(shuffleKey).put(epoch, (waitTime + 1, 
context))

Review Comment:
   waitTime -> use startTimestamp



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