bobbai00 commented on code in PR #9628:
URL: https://github.com/apache/texera/pull/9628#discussion_r4662629190


##########
amber/src/main/scala/org/apache/texera/web/service/ExecutionStatsService.scala:
##########
@@ -207,16 +216,57 @@ class ExecutionStatsService(
     client.registerCallback[ExecutionStateUpdate] {
       case ExecutionStateUpdate(state: WorkflowAggregatedState.Recognized)
           if state == COMPLETED || state == FAILED || state == KILLED =>
-        logger.info("Workflow execution terminated. Commit runtime 
statistics.")
+        commitAndStop()
+      case _ =>
+    }
+  )
+
+  /**
+    * Commits a run that never reported a terminal state, such as a user kill, 
when
+    * WorkflowService tears the service down: at the next run or on session 
cleanup. Nothing on
+    * those paths reads the statistics, so the commit finishes in the 
background.

Review Comment:
   **Polish:**
   
   One path does read them. A sync run that stops at `TargetResultsReady` is 
recorded COMPLETED without a terminal state 
(`SyncExecutionResource.scala:301-311`). The next run's `DefaultCostEstimator` 
then reads its statistics (`CostEstimator.scala:120-150`) and can race this 
commit. It only falls back to the port-count cost, so the background commit is 
fine; I'd state the real reason instead:
   
   ```suggestion
       * WorkflowService tears the service down: at the next run or on session 
cleanup. The commit
       * finishes in the background so the next run does not wait for it.
   ```



##########
amber/src/main/scala/org/apache/texera/web/service/ExecutionStatsService.scala:
##########
@@ -338,6 +388,9 @@ class ExecutionStatsService(
               )
             )
           }
+          // A failed run ends here without a terminal state, and the service 
is not torn down
+          // until the next run or session cleanup; commit now so the 
statistics can be read.

Review Comment:
   **Polish:**
   
   This callback records FAILED just above (line 380), and FAILED is one of the 
terminal states matched at line 218, so "without a terminal state" reads as a 
contradiction. What this path lacks is the engine's `ExecutionStateUpdate`:
   
   ```suggestion
             // A failed run ends here without the engine reporting a terminal 
state, and the
             // service is not torn down until the next run or session cleanup; 
commit now so the
             // statistics can be read.
   ```



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