fix(worker): exit 5 on gateway death, dedicated exit 8 on event-queue overflow (mxaccessgw#186)
A frame read that hits end of stream means the gateway closed its end of the pipe (usually because it died). WorkerApplication mapped every WorkerFrameProtocolException to ProtocolViolation (6); EndOfStream now exits as PipeConnectionFailed (5), alongside the IOException a broken pipe raises. Event-queue overflow exited as the generic UnexpectedFailure (1). The event drain loop now unwinds with WorkerEventQueueFaultException carrying the fault category, and QueueOverflow exits with the new WorkerExitCode.EventQueueOverflow (8). Other categories keep exit 1. The gateway does not decode worker exit codes (it only logs the number), so no gateway change is needed. WorkerBootstrap.md and MxAccessWorkerInstanceDesign.md updated. (mxaccessgw#186) Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using ZB.MOM.WW.MxGateway.Contracts.Proto;
|
||||
using ZB.MOM.WW.MxGateway.Worker.Bootstrap;
|
||||
using ZB.MOM.WW.MxGateway.Worker.Ipc;
|
||||
|
||||
@@ -158,6 +159,22 @@ public static class WorkerApplication
|
||||
|
||||
return (int)WorkerExitCode.Success;
|
||||
}
|
||||
catch (WorkerFrameProtocolException exception)
|
||||
when (exception.ErrorCode == WorkerFrameProtocolErrorCode.EndOfStream)
|
||||
{
|
||||
// A read that hits end of stream means the gateway closed its end of the pipe — most
|
||||
// often because the gateway process died. That is a lost connection, not a malformed
|
||||
// frame, so it exits as PipeConnectionFailed alongside the IOException a broken pipe
|
||||
// raises, rather than as ProtocolViolation.
|
||||
logger.Error("WorkerPipeConnectionFailed", new Dictionary<string, object?>
|
||||
{
|
||||
["exit_code"] = WorkerExitCode.PipeConnectionFailed,
|
||||
["error_code"] = exception.ErrorCode,
|
||||
["exception_type"] = exception.GetType().FullName,
|
||||
});
|
||||
|
||||
return (int)WorkerExitCode.PipeConnectionFailed;
|
||||
}
|
||||
catch (WorkerFrameProtocolException exception)
|
||||
{
|
||||
logger.Error("WorkerPipeProtocolFailure", new Dictionary<string, object?>
|
||||
@@ -169,6 +186,17 @@ public static class WorkerApplication
|
||||
|
||||
return (int)WorkerExitCode.ProtocolViolation;
|
||||
}
|
||||
catch (WorkerEventQueueFaultException exception)
|
||||
when (exception.Category == WorkerFaultCategory.QueueOverflow)
|
||||
{
|
||||
logger.Error("WorkerEventQueueOverflow", new Dictionary<string, object?>
|
||||
{
|
||||
["exit_code"] = WorkerExitCode.EventQueueOverflow,
|
||||
["exception_type"] = exception.GetType().FullName,
|
||||
});
|
||||
|
||||
return (int)WorkerExitCode.EventQueueOverflow;
|
||||
}
|
||||
catch (Exception exception) when (exception is IOException or TimeoutException)
|
||||
{
|
||||
logger.Error("WorkerPipeConnectionFailed", new Dictionary<string, object?>
|
||||
|
||||
Reference in New Issue
Block a user