Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors session management and pool scaling logic in the Bigtable client, ensuring that abnormally closed or failed sessions are properly replaced to maintain the minimum session count, and simplifying state transition handling. The review feedback suggests improving consistency in SessionPoolImpl.java by using a local openParams variable during session replacement, and refactoring manual polling in tests to use Awaitility for better robustness.
Code Review FindingsCONFIRMED bugs1. The new 2.
3.
4. Both comments describe the PLAUSIBLE bugs5. Same pattern as finding #3: asserts 6. The refactored 7. The inline scale-up while loops lack the 8. The replacement session is created with 9.
|
|
Review on my agent's confirmed bug 1 :) I think changing forceClose from WAIT_SERVER_CLOSE to CLOSE actually makes it semantically correct. It matches the original design: However, with this change, there is the risk: Heartbeat misses ARE session failures from the pool's perspective — the session is gone, a replacement must be created, and pending vRPCs need to tolerate this. The budget is supposed to cap how many times a vRPC retries before giving up, precisely to prevent a "query of death" from thrashing the pool. But there's a shape problem: consecutiveFailures is a pool-level counter, not a per-vRPC counter. The scenario that breaks it: t=0: Sessions S1–S5 all miss heartbeat simultaneously But: S1–S5 failing simultaneously is one "event" (e.g., brief network blip), The counter is meant to detect persistent failure (every new session I create immediately dies), but it's sensitive to burst failure (many sessions die at once in one wave). Two possible fixes: Option A — Per-session failure counts toward budget only when it dies before serving any vRPC: Option B — Threshold scales with pool size: Maybe we should consider option A so this change is less risky. |
This PR fixes session replacement and pool sizing issues in the Jetstream session pool:
forceClose()(SessionImpl):forceClose()previously set state directly toWAIT_SERVER_CLOSE, trickingSessionPoolImplinto treating abnormal closures (handshake timeouts, missed heartbeats) as graceful closes and skipping replacement. It now captures the originating state (STARTINGorREADY) and reports it to the pool listener.SessionList.onSessionClosed(): Switched from checkingprevStateto inspecting handle state (!afe.isPresent()for starting count;afeHandle.sessions.remove()for ready count). This prevents counter leaks on unexpected closure sequences and avoids double-decrements.SessionPoolImpl): Updatedstart(),onSessionClose(),onSessionGoAway(), and retry scheduling to create sessions whilepoolSizer.getScaleDelta() > 0and budget allows, while intentionally keeping the request hot path (PendingVRpc.start()) to a single session creation to avoid caller latency overhead.