Scripted alarms: every deploy re-activates a still-active alarm (Acked reset to Unacknowledged, new LastTransitionUtc, duplicate alerts row) #935
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?
Found while root-causing the A4 live gate (grpc-data condition forwarding, F2; branch
a4-code).ScriptedAlarmEngine.LoadAsyncruns on EVERY deploy (ApplyScriptedAlarms), clears_alarms, and seeds each alarm fromIAlarmStateStore.LoadAsync. The production store (LocalDbAlarmConditionStateStore) does not persistActive— it is restored asInactiveby design (docs/ScriptedAlarms.md§State persistence). With the predicate still true,Part9StateMachine.ApplyPredicate(seed Inactive, true)is an Inactive→Active transition:Activatedemission,Acked = Unacknowledged,Confirmed = Unconfirmed,LastTransitionUtc = now.Consequences on every deploy, for every still-active scripted alarm:
Activatedemission reaches thealertstopic → duplicate historian/AVEVA alarm row per deploy (the #487 re-assert was made node-only precisely to avoid this);Timemoves to the deploy instant (live:a4dbg-1origin records v16/v17 forsource-scalar-highat the deploy with the same state and marker,t= load time;re-asserted 1 non-normal condition node(s)then writesLastTransitionUtc).Startup_recovery_preserves_ack_but_rederives_active_from_predicatedoes not cover it: it seeds an InMemory store WITHActiveand the predicate goes false.Suggested fix: a same-process reload is a restatement, not a new occurrence — seed a surviving alarm id from the engine's previous in-memory condition (
previous ?? persisted ?? Fresh) before_alarms.Clear(), so a still-true predicate yieldsNone(the #487 re-assert still restores the node after a rebuild). Process restart keeps today's behaviour (Active not persisted).The A4 consumer-side fixes (held conditions across a deploy) make consumers mirror this restatement silently while state and marker are unchanged; the acked case is still wrong at the origin itself.
Fixed on master (merge of
fu-935). A same-process reload (deploy) now seeds each surviving scripted alarm from the previous generation's in-memory condition (previous ?? persisted ?? Fresh) — a still-true predicate is a restatement: no Activated, Acked kept, LastTransitionUtc and the activation marker unchanged, noalertsrow. Review round 1: operator commands look up under_evalGate(a command racing a load applies to the new generation), unchanged results are not saved (also stops a per-push replicated write), a failed load ends the generation (commands rejected with a Warning until the next good load, which reads the store like a restart), expired timed shelve at reload is unshelved with audit. Live: ack → deploy → still Acknowledged, same EventId, no event on origin or consumer; A01–A08 8/8. Evidence: docs/plans/evidence/followups/935.md.