feat(drivers): periodic reconcile of desired vs actual driver subscriptions #488
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?
Raised while reviewing the #485 subscription guard: is there a way to periodically check for actual subscriptions, to defend against races or a subscription dying silently?
What exists today
DriverInstanceActorholds_desiredRefsand re-asserts them on every Connected entry (ResubscribeDesired), so a reconnect self-heals.health-polltimer already exists — but it only callsIDriver.GetHealth()and publishes to the AdminUI. It never touches subscriptions.ISubscriptionHandleis opaque (just aDiagnosticIdstring), so the Core currently cannot ask a driver what it is actually subscribed to.The gap
Nothing detects a subscription that dies while the driver remains Connected — a server-side subscription drop, a session reset the driver does not surface as a disconnect, or a handle lost to an error path. The desired set is only re-applied on a connect transition or a deploy.
Two options
A — cheap, no interface change. A periodic invariant check in
DriverInstanceActor: while Connected, if_desiredRefs.Count > 0but_subscriptionHandle is null, self-tellSubscribe. This is a state-machine consistency check, not a true probe, but it needs no driver support and could ride the existinghealth-polltick.B — real reconcile, needs an interface change. Add a member to
ISubscribable(e.g.Task<IReadOnlyList<string>> GetSubscribedRefsAsync()), or liveness onISubscriptionHandle, then periodically diff desired vs actual and re-subscribe the difference. Requires implementing it across all 7 drivers (Modbus, S7, AB CIP/Legacy, TwinCAT, FOCAS, OpcUaClient) plus Galaxy, each with different subscription mechanics (polled vs native).Suggest A first — it is small and strictly additive — and only take B if a real occurrence shows the handle is present but dead.
Explicitly NOT this issue
This does not address deploy-time drift, which was #486 (a node claiming a revision it never applied). Re-asserting a desired set that is already correct would not have helped there. Keep the two separate.