fix(galaxy): #991 review — a re-advise pass never dials on a swapped session; dropped-event resync is rate-limited and coalesced

- ReadviseSubscriptionAsync: a reconnect completing between two subscriptions of a pass
  (dropped-event resync loop had no per-iteration check) sent the next SubscribeBulk to the
  NEW gateway session under the OLD session number; TryRebind refused it (SessionChanged)
  and the live new-session advises were never bound or released, then duplicated by the
  replay. The pass now refuses to dial once its session moved. Releasing afterwards was
  rejected: once the session moved, which session issued the reply's handles is ambiguous and
  old numbers are reused (#861); not dialling is the unambiguous fix.
- Dropped-event resync passes are at least 5 s apart (DropResyncMinInterval); drops reported
  meanwhile coalesce into the next pass, so repeated overflow bursts no longer churn
  re-advises into the overflowing channel.
- Test seams: ResyncDroppedHandlesForTestsAsync, NotifyEventsDroppedForTests,
  DropResyncMinIntervalForTests; AdvisingSubscriber gained after-subscribe/unsubscribe hooks.
This commit is contained in:
Joseph Doherty
2026-12-03 12:07:28 -05:00
parent 5dcb766fd1
commit eb78875c24
3 changed files with 137 additions and 1 deletions
+1 -1
View File
@@ -235,7 +235,7 @@ Every (re)open of `StreamAlarms` replays the gateway's active-alarm snapshot. `G
- **MXAccess `ClientName` collisions**: two OtOpcUa instances sharing a `ClientName` cause the older Wonderware session to lose subscription state. Redundancy pairs (decision #149) enforce uniqueness via install scripts.
- **Channel saturation**: `galaxy.events.dropped > 0` indicates `EventPump` is back-pressured. Raise `EventPumpChannelCapacity` or investigate downstream slowness in the server-side fan-out.
- **A dropped change is re-read (#991 G-4).** MXAccess sends a value only when it changes, so a data change the full channel drops (newest-dropped) used to leave its tag at the previous value, Good, until the attribute next changed. The pump records the item handles of dropped data changes and, once its channel has drained (so the resync is not lost to the same congestion), the driver re-advises exactly those tags — an advise is answered with the current value — rebinds them, and releases the superseded handles. One coalescing background worker; serialised with the replay-gap re-snapshot. The `galaxy.events.dropped` counter is unchanged; each burst logs one Warning ("re-reading them") and one Information line with the re-advised count.
- **A dropped change is re-read (#991 G-4).** MXAccess sends a value only when it changes, so a data change the full channel drops (newest-dropped) used to leave its tag at the previous value, Good, until the attribute next changed. The pump records the item handles of dropped data changes and, once its channel has drained (so the resync is not lost to the same congestion), the driver re-advises exactly those tags — an advise is answered with the current value — rebinds them, and releases the superseded handles. One coalescing background worker; serialised with the replay-gap re-snapshot. The `galaxy.events.dropped` counter is unchanged; each burst logs one Warning ("re-reading them") and one Information line with the re-advised count. **Rate-limited (#991 review):** passes are at least 5 s apart and drops reported meanwhile coalesce into the next pass — repeated overflow bursts used to start a pass as soon as the previous one ended, re-advising (and pushing initial values into) the very channel that was overflowing. **A pass whose gateway session is gone no longer dials:** a reconnect completing between two subscriptions of a re-advise pass (resync, replay-gap re-snapshot, reconnect replay) used to send the next SubscribeBulk to the NEW session under the OLD session number; the rebind refused it and those live advises were never bound or released (then duplicated by the new session's replay). They cannot simply be released afterwards — once the session has moved, which session issued a reply's handles is ambiguous and old numbers are reused (#861) — so the pass stops before dialling.
- **OPC DA limit bits do not warn (#991 G-2).** `StatusCodeMap.FromQualityByte` masks the two limit bits (`QQSSSSLL`) before its table lookup, so `Good | LowLimited` (0xC1) and friends map like the unlimited quality. A byte still unlisted after the mask logs one Warning per distinct value per process — it used to log one per event on the pump's dispatch thread, enough to back the channel up into drops.
- **The deploy watcher paces every stream end (#991 G-3).** A `WatchDeployEvents` stream the gateway completes cleanly is re-subscribed after the same capped exponential backoff as a faulted one (1 s doubling to 30 s), and the backoff resets only after a stream stayed open 60 s — an event alone (the bootstrap every stream delivers) no longer resets it. It used to re-open immediately, hammering a gateway that ends its streams after the bootstrap.
- **Secured / verified writes are REFUSED `BadUserAccessDenied`, locally (#991 G-1 + review).** The driver has no