fix(workers): orphan cleanup skips workers whose owning gateway is still running (WRK-009, #253)

This commit is contained in:
Joseph Doherty
2026-12-03 10:00:16 -05:00
parent 9c3a4c0eae
commit 87b8f8da09
6 changed files with 381 additions and 23 deletions
+11 -3
View File
@@ -1050,9 +1050,17 @@ Policy:
- stuck workers are killed by process id,
- gateway restart does not reattach old workers; `OrphanWorkerCleanupHostedService`
runs `OrphanWorkerTerminator` once on startup — before the server accepts
sessions — to kill leftover `ZB.MOM.WW.MxGateway.Worker.exe` processes (matched by the
configured worker executable path, or by image name when the x64 gateway cannot
introspect the x86 worker's module) left behind by a previous unclean run.
sessions — to kill leftover `ZB.MOM.WW.MxGateway.Worker.exe` processes left behind by
a previous unclean run. A candidate must match the configured worker executable path
(when its path is readable), and its command line's `--pipe-name`
(`mxgw-{gatewayPid}-{sessionUid}`) must name a gateway process that is no longer running
(or whose id was recycled: it started after the worker). A worker of a gateway that is
still running — a second gateway from the same build output, a test host — is left
alone. When neither the path nor the command line can be read, the process is left
alone and logged, since an image-name match alone could be another build's worker; when
the path matches but the command line cannot be read, the path decides, as before. The
command line is read with `NtQueryInformationProcess(ProcessCommandLineInformation)`,
which works from the x64 gateway on the x86 worker.
Because each client owns one worker, a crash or leak affects only that session.