[DSH-002] Dashboard live-read failure orphans its session and x86 worker for the 30-minute lease #248

Closed
opened 2026-12-02 16:07:36 -05:00 by dohertj2 · 1 comment
Owner

DSH-002 — Live-read failure orphans the dashboard session and worker

  • Severity: High — Category: Bug — Confidence: Confirmed code path; trigger frequency Plausible
  • Locations:
    • Dashboard/DashboardLiveDataService.cs:179-184 — catch-all calls InvalidateSession()
    • Dashboard/DashboardLiveDataService.cs:541-546 — InvalidateSession nulls _session without closing it
    • Dashboard/DashboardLiveDataService.cs:482-497 — EnsureReadyAsync closes the old session only when _session is still non-null
    • Sessions/GatewaySession.cs:2276-2282 — a bulk reply with non-Ok ProtocolStatus throws SessionManagerException while the session stays Ready
    • Configuration/SessionOptions.cs:13,21,80 — MaxSessions=64, DefaultLeaseSeconds=1800, UnattachedSessionGraceSeconds=0 (sweep disabled)

Description. Any non-cancellation exception in ReadAsync drops 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, transient SessionNotReady), 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 reaches MaxSessions and OpenSession is 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 CloseQuietlyAsync on it (still under _gate). Consider not invalidating on per-command failures that leave the session Ready.

Test idea. Fake ISessionManager whose session throws SessionManagerException from ReadBulkAsync; call ReadAsync twice; assert CloseSessionAsync was called for the first session id and at most one session is open.


Source: code-reviews/2026-12-02-perf-bugs/README.md and code-reviews/2026-12-02-perf-bugs/PLAN.md (commit f200bda6 on local branch docs/review-2026-12-02-perf-bugs, not yet pushed). Reviewed at 54367e74.

## DSH-002 — Live-read failure orphans the dashboard session and worker - **Severity:** High — **Category:** Bug — **Confidence:** Confirmed code path; trigger frequency Plausible - **Locations:** - `Dashboard/DashboardLiveDataService.cs:179-184` — catch-all calls `InvalidateSession()` - `Dashboard/DashboardLiveDataService.cs:541-546` — `InvalidateSession` nulls `_session` without closing it - `Dashboard/DashboardLiveDataService.cs:482-497` — `EnsureReadyAsync` closes the old session only when `_session` is still non-null - `Sessions/GatewaySession.cs:2276-2282` — a bulk reply with non-Ok `ProtocolStatus` throws `SessionManagerException` while the session stays Ready - `Configuration/SessionOptions.cs:13,21,80` — `MaxSessions=64`, `DefaultLeaseSeconds=1800`, `UnattachedSessionGraceSeconds=0` (sweep disabled) **Description.** Any non-cancellation exception in `ReadAsync` drops 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, transient `SessionNotReady`), 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 reaches `MaxSessions` and `OpenSession` is 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 `CloseQuietlyAsync` on it (still under `_gate`). Consider not invalidating on per-command failures that leave the session Ready. **Test idea.** Fake `ISessionManager` whose session throws `SessionManagerException` from `ReadBulkAsync`; call `ReadAsync` twice; assert `CloseSessionAsync` was called for the first session id and at most one session is open. --- Source: `code-reviews/2026-12-02-perf-bugs/README.md` and `code-reviews/2026-12-02-perf-bugs/PLAN.md` (commit `f200bda6` on local branch `docs/review-2026-12-02-perf-bugs`, not yet pushed). Reviewed at `54367e74`.
dohertj2 added the area:dashboardpriority:p1type:bugtype:review-finding labels 2026-12-02 16:07:36 -05:00
Author
Owner

Merged to main at 68043411 (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.

Merged to `main` at `68043411` (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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/mxaccessgw#248