fix(worker): count an unsubscribed alarm primary as failing and rebuild it (MXA-001, #249)

A wnwrap primary whose Subscribe failed polls as a silent no-op, so the
failover counter reset and probes read as clean: failover never engaged
(threshold 3) or falsely recovered onto a dead primary (threshold 1).
FailoverAlarmConsumer now tracks whether the current primary subscribed;
an unsubscribed primary is replaced by a fresh instance from the consumer
factory and subscribed before it is polled or probed, and a failure there
counts. Without a factory it reports the original subscribe HRESULT.
This commit is contained in:
Joseph Doherty
2026-12-03 09:44:11 -05:00
parent d12fd4f5a0
commit 58342efeab
4 changed files with 355 additions and 33 deletions
+7 -2
View File
@@ -210,11 +210,16 @@ The alarm feed has two providers, both implemented worker-side:
consecutive wnwrap COM failures — `Subscribe` or `PollOnce` throws or
returns a failure HRESULT — it activates the standby. The standby is armed
(subscribed and adviseing) from the start so its state is warm at the moment
of switch.
of switch. A primary whose `Subscribe` failed is not polled as if it were
healthy: wnwrap's `PollOnce` returns without touching COM until it is
subscribed, so each poll instead disposes the failed instance and subscribes
a fresh one, and a failure there counts toward the threshold.
- **Auto-failback:** while degraded, every `FailbackProbeIntervalSeconds`
(default 30) it re-probes the still-subscribed primary. After
`FailbackStableProbes` (default 3) consecutive clean polls it switches back
to the alarm manager.
to the alarm manager. If the primary never subscribed, the probe first
rebuilds and subscribes a fresh primary; until that succeeds every probe
fails, so the consumer never reports "recovered" onto a dead primary.
- **On every switch:** the consumer snapshots the now-active provider and
emits `OnAlarmProviderModeChangedEvent` so the gateway can reconcile its
cache without a raise/clear storm.