Merge fix/review-2026-12-phase2 (2026-12-02 review fix plan)

This commit is contained in:
Joseph Doherty
2026-12-03 10:18:43 -05:00
44 changed files with 2264 additions and 123 deletions
+30
View File
@@ -127,6 +127,20 @@ Startup sequence:
If validation fails before MXAccess creation, exit quickly with a non-zero exit
code. If MXAccess creation fails, send `WorkerFault` when possible and exit.
Steps 5–10 run under one deadline, `WorkerPipeSessionOptions.StartupHandshakeTimeout`,
which the launcher conveys as `MXGATEWAY_WORKER_STARTUP_TIMEOUT_MS` from
`MxGateway:Worker:StartupTimeoutSeconds` (default 120 s when absent). The worker
notices gateway death only through a pipe read returning end-of-stream or a
failed write, and the handshake has two windows with neither: a peer that
connects and never sends `GatewayHello` (net48 pipe reads ignore the
cancellation token), and MXAccess initialization, during which no read is
outstanding. A COM activation that hangs after the gateway died would otherwise
keep the x86 worker alive indefinitely. At the deadline the handshake throws
`TimeoutException` and the worker exits with `PipeConnectionFailed`; the stuck
step is abandoned, which is safe because the STA is a background thread. The
gateway applies the same budget to the whole launch and starts its clock first,
so a live gateway always gives up and kills the worker before this deadline.
The bootstrap layer returns structured exit codes before it creates pipes,
starts the STA, or touches MXAccess:
@@ -1165,6 +1179,22 @@ are rejected and queued commands that have not started receive
`ProtocolStatusCode.WorkerUnavailable`. The command already executing on the
STA is allowed to finish until the shutdown grace period expires.
The grace period covers the whole method, including the two alarm-side steps
that run before the data cleanup: joining the alarm poll loop and disposing the
alarm handler on the STA. Both wait on the STA, and neither can be cancelled
once its work item has started, so with the STA stuck in a COM call they used
to wait forever, the timeout below was never reached, and no shutdown-timeout
fault or `WorkerShutdownAck` was sent. Each step now gets what is left of the
grace, and running out raises the same `TimeoutException` as a slow data
cleanup.
The STA watchdog stands down once the session is `ShuttingDown` or `Stopped`.
The data cleanup runs as one STA work item, which leaves `LastStaActivityUtc`
frozen with no command correlation id on the heartbeat. With a grace longer than
`HeartbeatGrace`, the watchdog would otherwise overwrite `ShuttingDown` with
`Faulted` and report `StaHung` for a session that is closing cleanly. The
shutdown's own timeout bounds it instead.
After command dispatch is closed, cleanup runs on the STA in MXAccess handle
order: