[MXA-001] Alarm failover never engages when wnwrap primary fails to subscribe (PollOnce no-op resets counter) #249
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
MXA-001: Alarm failover never engages (or falsely "recovers") when the wnwrap primary fails to subscribe
MxAccess/WnWrapAlarmConsumer.cs:355-363(PollOncereturns silently when!subscribed)MxAccess/WnWrapAlarmConsumer.cs:188-281(subscribed = trueonly at the end ofSubscribe)MxAccess/FailoverAlarmConsumer.cs:137-157(Subscribe),:291-309(RunPrimary),:223-259(ProbeOnce)MxAccess/AlarmCommandHandler.cs:253-257(default threshold 3, stable probes 3)Description.
FailoverAlarmConsumer.Subscriberoutes the primary'sSubscribethroughRunPrimary, which swallows the exception and counts one failure.WnWrapAlarmConsumer.Subscribesetssubscribed = trueonly after all four wnwrap calls succeed, so after a failure it staysfalse. From then onWnWrapAlarmConsumer.PollOncereturns atif (disposed || !subscribed) return;without touching COM.RunPrimarytreats that silent return as success and resetsconsecutiveFailuresto 0.ProbeOncetreats it as a clean probe. Nothing ever re-subscribes the primary (ProbeOncedeliberately does not).Failure scenario.
SubscribeAlarmsruns, soInitializeConsumer/RegisterConsumer/Subscribereturn non-zero orSetXmlAlarmQuerythrows. That is failure 1 of 3. Every later poll is a no-op "success", so the counter never reaches 3. The consumer stays inAlarmmgrmode with a dead primary: no transitions, an emptyQueryActiveAlarmssnapshot, noOnAlarmProviderModeChanged, and no fault. The subtag standby is armed but gated off.FailbackStableProbesno-op probes (about 90 s at the defaults) the consumer announces "recovered" and switches back to the dead primary. The gateway then reconciles against an empty snapshot and clears every alarm the standby had reported.The unit tests miss this because the fake primary in
FailoverAlarmConsumerTeststhrows fromPollOncewhile unhealthy; the production consumer does not.Suggested fix. Make an unsubscribed primary count as unhealthy: either have
WnWrapAlarmConsumer.PollOncethrow whenSubscribewas attempted and failed, or haveFailoverAlarmConsumertrackprimarySubscribedand retryprimary.SubscribeinPollOnce/ProbeOnce(counting failures) instead of polling. A failed subscribe needs wnwrap deregistered first, or a fresh consumer instance.Test idea. A primary fake whose
Subscribethrows and whosePollOnceis a no-op (the wnwrap shape). Assert that afterThresholdpoll ticks the mode isSubtag, and thatProbeOncenever fails back until aSubscribesucceeds.Source:
code-reviews/2026-12-02-perf-bugs/README.mdandcode-reviews/2026-12-02-perf-bugs/PLAN.md(commitf200bda6on local branchdocs/review-2026-12-02-perf-bugs, not yet pushed). Reviewed at54367e74.Merged to
mainat68043411(pushed 2026-12-03). Gateway suite 1610 passed / 0 failed (macOS); windev worker CI 836 passed / 0 failed on that SHA.Subscribe failure counts as a failure; recovery subscribes a fresh wnwrap instance and fails back only after success. Live rig check not run (rig alarms are object-driven).