feat(worker,gateway): report record-info pin outcome in WorkerReady; drain-thread completion tests
The worker logged its MXSTATUS_PROXY record-info pin outcome only to its own stderr, which the gateway's launcher does not capture, so operators never saw whether the pin took. - Contract (additive, internal IPC): WorkerReady.record_info_pin_status = 5. No protocol version bump; an older peer ignores it or sends it empty. Regenerated Contracts/Generated, the client protoset, the Rust vendored proto, and the Go/Python/Java worker bindings (real delta only). - Worker: the handshake copies MxStatusProxyRecordInfoPin.Status into WorkerReady unless the runtime already set it. - Gateway: WorkerClient records it (IWorkerClient.RecordInfoPinStatus, default null) and logs it at Information when pinned, Warning otherwise; empty is not logged. Shown as "Record-info pin" in the dashboard session details Worker table via DashboardSessionSummary.WorkerRecordInfoPinStatus. - Tests: drain-thread cancellation (task ends Canceled; RunAsync cancels, runtime disposed, thread exits, no EventDrain stop-failure log) and fault (exception on the thread faults RunAsync with the same instance) paths; WorkerReady carries the pin status; gateway logging/recording and the dashboard projection. - Docs: gateway.md STA thread model (drain thread, pin step in COM lifetime), MxAccessWorkerInstanceDesign, GatewayProcessDesign, GatewayDashboardDesign, WorkerFrameProtocol.
This commit is contained in:
+31
-7
@@ -837,16 +837,30 @@ STA thread
|
||||
|
||||
MXAccess event handler on STA
|
||||
-> convert event args to WorkerEvent
|
||||
-> enqueue outbound event
|
||||
-> enqueue outbound event, signal the drain thread
|
||||
|
||||
pipe writer thread
|
||||
-> dequeue replies/events
|
||||
-> write framed protobuf messages
|
||||
event drain thread (mxgw-event-drain, dedicated, not thread pool)
|
||||
-> park on the event queue's wake signal
|
||||
-> drain a batch of WorkerEvents
|
||||
-> write them as one framed batch, flushed synchronously
|
||||
|
||||
command replies and heartbeats
|
||||
-> written through the same frame writer, which orders control frames
|
||||
ahead of queued events
|
||||
```
|
||||
|
||||
Do not block the STA on pipe writes or gRPC calls. The STA should enqueue
|
||||
results/events and return to pumping messages.
|
||||
|
||||
The event drain loop has its own background thread because of the .NET
|
||||
Framework thread pool. As an async loop, every event woke a pool worker, and
|
||||
each one spun before parking again; a production trace put that spin at about a
|
||||
quarter of the worker's CPU at ~240 events/s. The dedicated thread parks on the
|
||||
signal, and with a synchronous flush the steady-state event path queues no pool
|
||||
work. The drain loop's task still completes, faults or cancels exactly as the
|
||||
loop does, so the session's supervision of it is unchanged. See
|
||||
`docs/MxAccessWorkerInstanceDesign.md`.
|
||||
|
||||
### Message Pump
|
||||
|
||||
The STA loop must pump Windows messages and service command work. A typical
|
||||
@@ -878,9 +892,19 @@ Worker startup:
|
||||
|
||||
1. set apartment state to STA,
|
||||
2. initialize COM on the STA,
|
||||
3. instantiate `LMXProxyServerClass` or the installed MXAccess interop class,
|
||||
4. attach event handlers,
|
||||
5. send `WorkerReady`.
|
||||
3. pin the LMXProxy type library and the `MXSTATUS_PROXY` record info for the
|
||||
process lifetime (once per process, best effort),
|
||||
4. instantiate `LMXProxyServerClass` or the installed MXAccess interop class,
|
||||
5. attach event handlers,
|
||||
6. send `WorkerReady`, carrying the pin outcome in `record_info_pin_status`.
|
||||
|
||||
The pin exists because `lmxproxy.dll` looks up the `MXSTATUS_PROXY` record type
|
||||
for every `OnDataChange`. With no live reference to it, oleaut32 re-reads the
|
||||
registry and reloads the type library on each call, which a production trace put
|
||||
at about 70% of the STA's CPU. Holding one reference makes the lookup a cache
|
||||
hit. A failed pin is never fatal, since MXAccess behaves the same either way, but
|
||||
the gateway logs it as a warning and shows it on the dashboard's session details
|
||||
page, because the worker's own stderr is not captured.
|
||||
|
||||
Worker shutdown:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user