fix(worker): bound shutdown alarm steps by the grace; watchdog stands down while shutting down; startup handshake deadline (MXA-003, WIP-007, WIP-009, #253)
ci / windows-x86 (push) Failing after 11m18s
ci / java (push) Failing after 11m43s
ci / portable (push) Failing after 12m6s
ci / windows-x86 (push) Failing after 11m18s
ci / java (push) Failing after 11m43s
ci / portable (push) Failing after 12m6s
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -1155,6 +1169,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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user