fix(comm): key site liveness on central receive time; gRPC connect timeout + connect-phase deadline failover (COMM-4, COMM-5, WP4 task 4.4)

This commit is contained in:
Joseph Doherty
2026-12-03 09:52:54 -05:00
parent c1db7094eb
commit f02fe9d696
18 changed files with 350 additions and 38 deletions
@@ -271,11 +271,17 @@ Three layers of dead-client detection prevent orphan streams on site nodes:
Keepalive settings are configurable via `CommunicationOptions`:
- `GrpcKeepAlivePingDelay`: 15 seconds (default)
- `GrpcKeepAlivePingTimeout`: 10 seconds (default)
- `GrpcConnectTimeout`: 5 seconds (default, validated positive) — `SocketsHttpHandler.ConnectTimeout` on every cross-cluster channel (central→site command pair, site→central control pair, site stream clients). See *Black-holed peers* below.
- `GrpcMaxStreamLifetime`: 4 hours (default)
- `GrpcMaxConcurrentStreams`: 100 (default)
- `GrpcStreamBatchMaxEvents`: 100 (default) — see Event Batching above
- `GrpcStreamBatchWindow`: 25 ms (default) — see Event Batching above
**Black-holed peers (COMM-5, 2026-12).** A peer whose host silently drops SYNs (powered off behind a router, firewall drop, WAN black hole) used to hold every connect for the OS TCP timeout (~21 s on Windows, ~2 min on Linux), so calls with shorter deadlines ended `DeadlineExceeded` — which neither channel pair failed over on — and a dead node kept every command. Three changes close it:
- `GrpcConnectTimeout` (5 s) makes the connect fail as `Unavailable` ("Error connecting to subchannel.", `TimeoutException` cause) well inside every call deadline. That shape is also recognised by `GrpcRetrySafety.WasNeverSent`, so even a mutation fails over within the call — the request provably never left the client.
- A `DeadlineExceeded` that expires while the channel is still `Connecting`/`TransientFailure` (`GrpcRetrySafety.IsConnectPhaseDeadline`) moves the pair: `SitePairChannelProvider` flips NodeA↔NodeB, `GrpcCentralTransport` flips central-a↔central-b (heartbeat included, so a quiet site leaves a dead central). The deadline is spent, so the call itself is not retried; a deadline on a connected (`Ready`) channel is a slow peer and moves nothing.
- The Alarm Summary aggregator's stream **open deadline** is now a stream error (flip node, spend a retry) rather than only a release of the in-flight guard; before, the next reconcile tick reopened on the same black-holed node indefinitely.
### 6a. Debug Snapshot (Central → Site)
- **Pattern**: Request/Response (one-shot, no subscription).
- Central sends a `DebugSnapshotRequest` (identified by instance unique name) to the site.