[DSH-002] Dashboard live-read failure orphans its session and x86 worker for the 30-minute lease #248
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?
DSH-002 — Live-read failure orphans the dashboard session and worker
Dashboard/DashboardLiveDataService.cs:179-184— catch-all callsInvalidateSession()Dashboard/DashboardLiveDataService.cs:541-546—InvalidateSessionnulls_sessionwithout closing itDashboard/DashboardLiveDataService.cs:482-497—EnsureReadyAsynccloses the old session only when_sessionis still non-nullSessions/GatewaySession.cs:2276-2282— a bulk reply with non-OkProtocolStatusthrowsSessionManagerExceptionwhile the session stays ReadyConfiguration/SessionOptions.cs:13,21,80—MaxSessions=64,DefaultLeaseSeconds=1800,UnattachedSessionGraceSeconds=0(sweep disabled)Description. Any non-cancellation exception in
ReadAsyncdrops the reference to the dashboard's session. If the session did not fault (command timeout, non-Ok protocol status on a bulk subscribe or read, transientSessionNotReady), it stays in the registry as Ready with a live x86 worker and up to 256 advised tags. Nothing references it, so the fault sweep does not apply and the unattached-grace sweep is off by default; it lives until the 30-minute lease expires. The next Browse poll opens a new session and worker.Failure scenario. An operator has a Browse page open with watched tags. The worker answers a bulk read with a non-Ok protocol status, or a command times out, repeatedly. The page polls every 2 s (
BrowsePage.razor:603); each failing poll opens a fresh session and leaks the previous one. Within minutes the registry reachesMaxSessionsandOpenSessionis refused for real gRPC clients (OtOpcUa, ScadaBridge) for up to 30 minutes, with dozens of orphan worker processes still pumping events.Suggested fix. In the catch block, capture the session id before invalidating and call
CloseQuietlyAsyncon it (still under_gate). Consider not invalidating on per-command failures that leave the session Ready.Test idea. Fake
ISessionManagerwhose session throwsSessionManagerExceptionfromReadBulkAsync; callReadAsynctwice; assertCloseSessionAsyncwas called for the first session id and at most one session is open.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.Live-read failure (and a failed Register on a new session) closes the session; DSH-007 unadvise fixed too.