eugenegujing opened a new pull request, #9344:
URL: https://github.com/apache/texera/pull/9344

   ### What changes were proposed in this PR?
   
   **Root cause.** `AdvanceRegionExecutionsHandler` reports a failed advance to 
the client through `.onFailure` on the future returned by 
`WorkflowExecutionManager.advanceRegionExecutions`. That method does work 
before any future exists: it eagerly maps 
`syncStatusAndTransitionRegionExecutionPhase()` over the unfinished regions, 
and entering a region's non-dependee phase runs 
`createOutputPortStorageObjects` synchronously, which throws when an output 
port's schema cannot be resolved or when the storage layer fails. Such an 
exception left the handler before `.onFailure` was attached. `AsyncRPCServer` 
caught it and returned a `ControlError` to the requester, but the requester is 
the coordinator itself (`PortCompletedHandler` sends the request and discards 
the reply), so nothing consumed the error: no `FatalError` reached the client 
and the execution stayed RUNNING with no region advancing.
   
   ```text
   Before:  port completed -> advance RPC -> createOutputPortStorageObjects 
throws -> ControlError to coordinator (discarded) -> UI: Running forever
   After:   port completed -> advance RPC -> createOutputPortStorageObjects 
throws -> failed future -> onFailure -> FatalError to client
   ```
   
   **Change.** The call is wrapped as 
`Future(cp.workflowExecutionManager.advanceRegionExecutions(cp.actorService)).flatten`,
 so a synchronous throw becomes a failed future and takes the same `onFailure` 
path as an asynchronous failure. The handler still returns `EmptyReturn()` 
immediately without awaiting the advance.
   
   **Scope.** `PortCompletedHandler` still discards the reply by design (it 
must not await the advance in its own control round); the fix makes the handler 
self-sufficient instead of changing the caller.
   
   ### Any related issues, documentation, discussions?
   
   Closes #9343
   
   ### How was this PR tested?
   
   Added to `AdvanceRegionExecutionsHandlerSpec`, with a 
`WorkflowExecutionManager` stub whose `advanceRegionExecutions` throws 
synchronously:
   
   - a `WorkflowRuntimeException` with a related worker id produces exactly one 
`FatalError(err, Some(workerId))` and the handler still returns `EmptyReturn`;
   - a plain `IllegalStateException` produces exactly one `FatalError(err, 
None)`;
   - dispatched through `processDCM` and the real `AsyncRPCServer`, the reply 
to the coordinator is the ordinary `ReturnInvocation(id, EmptyReturn())` rather 
than a `ControlError`, and exactly one message of any kind reaches the client, 
the `FatalError`;
   - a `WorkflowRuntimeException` with no related worker id produces exactly 
one `FatalError(err, None)`;
   - a fatal throwable (`LinkageError`) is not converted: it still escapes the 
handler, the RPC server answers the coordinator with a `ControlError`, and 
nothing is sent to the client, so the change only affects non-fatal failures.
   
   The existing tests for a failed future, a successful advance and the 
immediate reply are unchanged.
   
   ```
   sbt "WorkflowExecutionService/testOnly 
org.apache.texera.amber.engine.architecture.coordinator.promisehandlers.AdvanceRegionExecutionsHandlerSpec
 
org.apache.texera.amber.engine.architecture.coordinator.promisehandlers.PortCompletedHandlerSpec"
   ```
   
   - Red (tests against unmodified source): sbt summary `succeeded 13, failed 
4` across the two specs (AdvanceRegionExecutionsHandlerSpec 7 passed / 4 
failed, PortCompletedHandlerSpec 6 passed / 0 failed; the LinkageError test 
passes either way because it pins the pre-existing fatal-throwable path); the 
RPC-dispatched case recorded `ReturnInvocation(11, 
ControlError("java.lang.IllegalStateException: Failed to resolve the output 
schema", ...))` and no client event.
   - Green (with this change): `succeeded 17, failed 0` 
(AdvanceRegionExecutionsHandlerSpec 11 / 0 with 5 new tests, 
PortCompletedHandlerSpec 6 / 0).
   - Mutation check: restoring the unwrapped call fails 4 of the 5 new tests 
(AdvanceRegionExecutionsHandlerSpec 7 passed / 4 failed; the LinkageError test 
is unaffected by design); restored afterwards.
   - `sbt WorkflowExecutionService/scalafmtCheck 
WorkflowExecutionService/Test/scalafmtCheck "WorkflowExecutionService/scalafix 
--check" "WorkflowExecutionService/Test/scalafix --check"`: all pass.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Yes. Generated-by: Claude Code (claude-fable-5-1). Co-authored with Claude; 
the author reviewed the change before submission.


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