Yicong-Huang commented on code in PR #7122:
URL: https://github.com/apache/texera/pull/7122#discussion_r3785196731


##########
amber/src/main/scala/org/apache/texera/amber/engine/architecture/scheduling/RegionExecutionManager.scala:
##########
@@ -195,41 +210,41 @@ class RegionExecutionManager(
           }
       }.toSeq
 
-    val endWorkerFuture: Future[Unit] =
-      Future.collect(endWorkerRequests).unit
-
-    // 2. Send GracefulStops only after 1 has finished
-    val gracefulStopRequests: Future[Unit] =
-      endWorkerFuture.flatMap { _ =>
-        val gracefulStops =
-          regionExecution.getAllOperatorExecutions.flatMap {
-            case (_, opExec) =>
-              opExec.getWorkerIds.map { workerId =>
-                val actorRef = actorRefService.getActorRef(workerId)
-                // Remove the actorRef so that no other actors can find the 
worker and send messages.
-                actorRefService.removeActorRef(workerId)
-                // Restarted regions reuse actorId. Remove stale control 
channels so the
-                // coordinator does not reuse old control-message sequence 
numbers for new workers.
-                asyncRPCClient.inputGateway.removeControlChannel(workerId)
-                asyncRPCClient.outputGateway.removeControlChannel(workerId)
-                gracefulStop(actorRef, ScalaDuration(5, 
TimeUnit.SECONDS)).asTwitter()
-              }
-          }.toSeq
+    val terminationAttempt =
+      Future
+        .collect(endWorkerRequests)
+        .unit
+        .flatMap { _ =>
+          // 2. Only send GracefulStops after all EndWorkers have succeeded.
+          val gracefulStopRequests =
+            regionExecution.getAllOperatorExecutions.flatMap {
+              case (_, opExec) =>
+                opExec.getWorkerIds.map { workerId =>
+                  val actorRef = actorRefService.getActorRef(workerId)
+                  gracefulStop(actorRef, ScalaDuration(5, 
TimeUnit.SECONDS)).asTwitter()

Review Comment:
   Verified: fixed. `gracefulStop` now reads the constant — 
`RegionExecutionManager.DefaultGracefulStopTimeoutMs` at `:224`, inside the 
call opening at `:221` — so `grep` returns three occurrences instead of two, 
and the 5s/1s split is enforced by the code rather than only stated in the 
comment. Either half of the budget can now be edited from one place. Resolving.



##########
amber/src/test/scala/org/apache/texera/amber/engine/architecture/scheduling/RegionExecutionManagerTestSupport.scala:
##########
@@ -79,7 +82,8 @@ object RegionExecutionManagerTestSupport {
 
   case class CoordinatorHarnessFixture(
       actorService: PekkoActorService,
-      actorRefService: PekkoActorRefMappingService
+      actorRefService: PekkoActorRefMappingService,
+      coordinatorRef: ActorRef

Review Comment:
   Verified: fixed. `coordinatorRef` is gone from both 
`CoordinatorHarnessFixture` (`:80-83`) and the constructor call (`:264-267`), 
and `grep -rn "\.coordinatorRef" amber/src/test` finds no reader. Resolving.



##########
amber/src/main/scala/org/apache/texera/amber/engine/architecture/scheduling/RegionExecutionManager.scala:
##########
@@ -185,7 +198,9 @@ class RegionExecutionManager(
   }
 
   private def terminateWorkers(regionExecution: RegionExecution) = {
-    // 1. Send EndWorkers to every worker
+    implicit val timer: Timer = killRetryTimer
+    val killTimeout = 
com.twitter.util.Duration.fromMilliseconds(terminationTimeoutMs)
+    // 1. Send EndWorkers with timeout

Review Comment:
   Verified: fixed. `:200` now reads `// 1. Send EndWorkers to every worker.`, 
so the step label no longer attributes the `.within` bound to step 1. Resolving.



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