Skip to content

docs(bigtable): clarify session close, cancelRpc, and heartbeat invariants - #15000

Open
igorbernstein2 wants to merge 1 commit into
mainfrom
docs-clarify-session-close-and-cancel-contract
Open

igorbernstein2 wants to merge 1 commit into
mainfrom
docs-clarify-session-close-and-cancel-contract

Conversation

@igorbernstein2

Copy link
Copy Markdown
Contributor

Clarifies the Session lifecycle, cancelRpc, and server heartbeat/deadline contracts in Session and SessionImpl:

  • Fix misleading Javadoc on Session.close() (which previously described immediate abort like forceClose() rather than graceful drain via CLOSING -> WAIT_SERVER_CLOSE) and document how each SessionState is bounded.
  • Document in SessionImpl.cancelRpc() and SessionImpl.close() why currentRpc remains set after local cancellation until the server replies (the protocol does not yet have a wire cancel-vRPC message, so keeping currentRpc set prevents returning a READY session to the pool while the vRPC is still active on the server and prevents sending CloseSessionRequest while a vRPC is still in flight on the server).
  • Document in SessionImpl.checkCloseTimeout() why closeTimeout only needs to bound WAIT_SERVER_CLOSE (CLOSING only occurs while a vRPC is active on the wire, which is bounded by server heartbeats via checkHeartbeat() and the server-enforced VirtualRpcRequest.deadline).

@igorbernstein2
igorbernstein2 requested review from a team as code owners November 13, 2026 16:35

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the documentation and inline comments in Session.java and SessionImpl.java to clarify the Session V3 protocol state transitions, graceful close behavior, RPC cancellation mechanics, and timeout handling. Specifically, it explains why a session waits in the CLOSING state during active vRPCs and details the server-side invariants bounding this state. There are no review comments, and I have no additional feedback to provide.

* sent. Bounded by server heartbeats ({@code checkHeartbeat}) and the server-enforced
* {@code VirtualRpcRequest.deadline}.
* <li>{@link #WAIT_SERVER_CLOSE}: No vRPC is in flight on the wire (so server heartbeats stop)
* and {@code CloseSessionRequest} + {@code halfClose()} have been sent; waiting for the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, i just realized, we send another CloseSessionRequest when watchdog kills the session, is it gonna be redundant? maybe log a debug tag is enough?

public void cancelRpc(long rpcId, @Nullable String message, @Nullable Throwable cause) {
sessionSyncContext.execute(
() -> {
// The Session V3 protocol does not yet have a wire cancel-vRPC message, so the server

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is V3 protocol?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants