OpcUaClient: stale BadNoSubscription after a normal resubscribe is declared subscription loss (ConnectionLost) #763

Closed
opened 2026-11-09 12:36:38 -05:00 by dohertj2 · 1 comment
Owner

OpcUaClientDriver.HandlePublishError (~line 3347) treats any BadNoSubscription as loss of a tracked subscription: tracked is true whenever any subscription exists, so a late BadNoSubscription (0x80790000, subscriptionId=0) belonging to a subscription the driver itself just deleted triggers DeclareSubscriptionLost → BadNoCommunication quality annotation on alarms + ConnectionLost. In production a routine unsubscribe→resubscribe can therefore make the host re-initialise the driver.

Found as the root cause of #728 (ConditionRefresh wire test, reproduced 5/6 locally). Fix options: ignore BadNoSubscription for a short grace window after the last tracked subscription is deleted, or verify a tracked subscription id is actually gone before declaring loss. Land with #728's test diagnostics (record message/severity/quality/AlarmType).

`OpcUaClientDriver.HandlePublishError` (~line 3347) treats any `BadNoSubscription` as loss of a tracked subscription: `tracked` is true whenever *any* subscription exists, so a late `BadNoSubscription` (0x80790000, subscriptionId=0) belonging to a subscription the driver itself just deleted triggers `DeclareSubscriptionLost` → BadNoCommunication quality annotation on alarms + `ConnectionLost`. In production a routine unsubscribe→resubscribe can therefore make the host re-initialise the driver. Found as the root cause of #728 (ConditionRefresh wire test, reproduced 5/6 locally). Fix options: ignore BadNoSubscription for a short grace window after the last tracked subscription is deleted, or verify a tracked subscription id is actually gone before declaring loss. Land with #728's test diagnostics (record message/severity/quality/AlarmType).
dohertj2 added the driver/opcuaclienttype:bugpriority:p2 labels 2026-11-09 12:36:38 -05:00
Author
Owner

Fixed on master 0217d36c. A BadNoSubscription naming a subscription id now counts only if the id is tracked (same rule as BadSubscriptionIdInvalid). An anonymous (id 0) BadNoSubscription within StaleNoSubscriptionGrace (5 s) of a delete that left the driver tracking nothing is ignored (Debug log); window stamped on removal and restarted when the delete completes, also stamped by failed-subscribe cleanup, reset on session release; a delete that leaves another subscription tracked opens no window. Genuine loss inside the window is still caught by the publishing-stall heuristic (only the immediate ConnectionLost is forgone). Documented in docs/drivers/OpcUaClient.md.

Evidence: new OpcUaClientStaleNoSubscriptionTests (7) — 3 stale-error cases fail with the old HandlePublishError; 4 genuine-loss controls pass both ways; mutation-checked (window on any delete / never expiring / no session reset each fail a test). OpcUaClient driver tests 293/293, OpcUaServer.IntegrationTests 127/127, driver integration 5/5.

Fixed on master 0217d36c. A BadNoSubscription naming a subscription id now counts only if the id is tracked (same rule as BadSubscriptionIdInvalid). An anonymous (id 0) BadNoSubscription within `StaleNoSubscriptionGrace` (5 s) of a delete that left the driver tracking nothing is ignored (Debug log); window stamped on removal and restarted when the delete completes, also stamped by failed-subscribe cleanup, reset on session release; a delete that leaves another subscription tracked opens no window. Genuine loss inside the window is still caught by the publishing-stall heuristic (only the immediate ConnectionLost is forgone). Documented in docs/drivers/OpcUaClient.md. Evidence: new OpcUaClientStaleNoSubscriptionTests (7) — 3 stale-error cases fail with the old HandlePublishError; 4 genuine-loss controls pass both ways; mutation-checked (window on any delete / never expiring / no session reset each fail a test). OpcUaClient driver tests 293/293, OpcUaServer.IntegrationTests 127/127, driver integration 5/5.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/lmxopcua#763