[SEC-005] Alarm monitor restart drops cache without Clear/provider-status frames; cleared alarms stay active downstream #250
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?
SEC-005 — Monitor restart silently drops the cache; subscribers keep stale alarms
Alarms/GatewayAlarmMonitor.cs:330-342(finally →ClearCache),1007-1020,237-245,884-937.Description.
StreamAsyncsubscribers deliberately outlive the monitor's worker session. When a lifecycle ends (worker crash, lease overflow, command failure)ClearCacheempties_alarmswith noClearbroadcast. After the restart the firstApplyReconcilediffs the new snapshot against the empty cache, so it emits onlyRaiserepairs. An alarm that cleared while the monitor was down is in neither set and gets noClear. Separately, the lifecycle start re-baselines_providerMode/_providerDegraded/_providerReason(lines 237-245) withoutBroadcastToAll.Failure scenario. OtOpcUa holds a
StreamAlarmsstream. AlarmGalaxy!Area.Tank01.HiHiis active. The worker faults; the monitor restarts after 5 s plus worker startup. The alarm returns to normal during that gap. The new reconcile does not contain it, the cache is already empty, and noClearis ever sent. OtOpcUa shows the alarm active until its own stream reconnects, which may be never. Likewise a subscriber that last sawSubtag / degradedkeeps showing degraded after the restart lands back on the alarm manager, because Auto mode raises no mode-change event at start.Suggested fix. Keep the previous generation for diffing instead of clearing it (hide it from
CurrentAlarmswhile notMonitoring), so the first reconcile of the new lifecycle emits the missingClears. Alternatively broadcastClearfor every cached alarm inClearCache. Broadcast the provider status after the re-baseline.Test idea. Fake session manager: reconcile returns {A, B}; attach a subscriber; end the event stream to force a restart; second lifecycle's reconcile returns {A}. Assert the subscriber receives
Clearfor B. Second test: assert aProviderStatusframe after a restart from Subtag.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.Restart keeps the old cache and the first reconcile diffs against it, emitting Clear repairs + provider status (see
gateway.md). DSH-005 hub priming added.