You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
新增 SessionPool.CheckHealthAsync 连通性探针
IsOpen() is a lifecycle flag - it reports whether the caller has opened the pool
and not yet closed it. Because the client keeps no heartbeat, it stays true after
the server goes down, and users routinely mistake it for a health check, e.g.
`if (pool.IsOpen()) return;` in a lazy-open guard, which then never rebuilds the
pool. This adds the connectivity check that IsOpen() is mistaken for, without
changing IsOpen() itself.
IsOpen() 是生命周期标志,仅表示调用方是否已打开且尚未关闭连接池。由于客户端无心跳,
服务端断开后它仍为 true,用户普遍将其误当作健康检查(例如惰性打开守卫里的
`if (pool.IsOpen()) return;`),从而导致连接池永远不会被重建。本提交新增了
IsOpen() 被误认为具备的连通性检查能力,且不改变 IsOpen() 自身行为。
- Add SessionPool.CheckHealthAsync(CancellationToken), which issues one lightweight
request on an idle pooled connection and returns a SessionPoolHealth snapshot
carrying Status, AvailableClients, TotalPoolSize, FailedReconnections, Message
and the underlying Error.
新增 SessionPool.CheckHealthAsync(CancellationToken):在空闲连接上发送一次轻量请求,
返回包含状态、可用连接数、池容量、重连失败次数、说明和底层异常的 SessionPoolHealth 快照。
- Add SessionPoolHealthStatus with four outcomes: NotOpen (no network call is made),
Healthy, Degraded (open but no idle connection to probe with - a saturation signal,
not a server verdict) and Unhealthy (a connection was available but the server did
not answer).
新增 SessionPoolHealthStatus 四种结果:NotOpen(不发起网络调用)、Healthy、
Degraded(池已打开但无空闲连接可用于探测,表示饱和而非服务端故障)、
Unhealthy(有可用连接但服务端未响应)。
- Add ConcurrentClientQueue.TryTake so the probe never blocks. A health endpoint
must not queue behind application load, so when every client is busy the probe
returns Degraded immediately instead of waiting.
新增 ConcurrentClientQueue.TryTake 使探针永不阻塞:健康检查端点不应排在业务负载之后,
因此所有连接繁忙时立即返回 Degraded 而不是等待。
- The borrowed connection is always returned to the pool and a failed probe does not
close it, so the existing reconnect-on-use path is unchanged.
借出的连接总会归还池中,探测失败也不会关闭它,因此既有的按需重连路径保持不变。
- Forward CheckHealthAsync from TableSessionPool with identical semantics.
TableSessionPool 以相同语义转发 CheckHealthAsync。
- Add tests for the NotOpen path, non-blocking TryTake semantics and the health
snapshot; document the API in docs/SessionPool_Exception_Handling.md and docs/API.md.
补充 NotOpen 路径、TryTake 非阻塞语义与健康快照的测试;在相关文档中说明该 API。
| Open | bool | open session | session_pool.Open(false) |
46
46
| Close | null | close session | session_pool.Close() |
47
-
| IsOpen | null | check if the pool was opened and not yet closed by the caller. It is a lifecycle flag, **not** a connectivity probe: it stays `true` after the server goes down, because the client keeps no heartbeat and reconnects on demand instead. | session_pool.IsOpen() |
47
+
| IsOpen | null | check whether the pool was opened and not yet closed by the caller. It is a lifecycle flag, **not** a connectivity probe: it stays `true` after the server goes down, because the client keeps no heartbeat and reconnects on demand instead. For connectivity use `CheckHealthAsync`| session_pool.IsOpen() |
48
+
| CheckHealthAsync | CancellationToken=default | probe server connectivity on an idle pooled connection; returns a `SessionPoolHealth` snapshot | await session_pool.CheckHealthAsync() |
0 commit comments