Repository navigation
feat(flight)!: support CloseSession - #12237
Open
Phoenix500526 wants to merge 1 commit into
Open
Phoenix500526 wants to merge 1 commit into
Phoenix500526 wants to merge 1 commit into
Conversation
Phoenix500526
marked this pull request as ready for review
November 13, 2026 15:06
This was referenced Nov 13, 2026
Phoenix500526
force-pushed
the
issue/6516
branch
from
November 15, 2026 11:32
3e9d068 to
240cd9c
Compare
Allow Flight SQL clients to release server sessions and inspect the reported status. Support manual verification with the example server and the CLI close-session command. BREAKING CHANGE: FlightSqlServiceClient::close now returns Result<CloseSessionResult> instead of Result<()> and sends a server request instead of succeeding without doing anything. Callers are responsible for handling the returned close status. CloseSession actions now dispatch to do_action_close_session instead of do_action_fallback. Servers that handled CloseSession in the fallback should move that logic to the new method; its default implementation returns Unimplemented. CLOSE apache#6516
Phoenix500526
force-pushed
the
issue/6516
branch
from
November 16, 2026 02:42
240cd9c to
6b84578
Compare
Contributor
Author
|
@kou in case you're interested in this. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Part of #11383
Closes #6516.
Rationale for this change
Flight SQL clients need a standard way to notify a server that a session can be released. The discussion started in arrow-flight-sql-postgresql#13: waiting for session timeout retains server resources after the client has finished, while server-specific close actions prevent generic clients from handling this consistently. apache/arrow#34817 introduced the standard session-management messages, including
CloseSession.As reported in #6516, clients such as
adbc_driver_flightsqlalready send this action, but the Rust Flight SQL server does not recognize it. Implementors currently need ado_action_fallbackworkaround. The Rust SQL client'sclose()is also a no-op, so calling it does not release a server session.This PR implements the Rust client and server support. The PostgreSQL adapter still needs its own server implementation; this does not resolve that separate issue.
What changes are included in this PR?
CloseSessionRequestandCloseSessionResulttoFlight.proto, regenerate the Rust bindings, and export both messages andclose_session_result::Status.FlightSqlServiceClient::close()using the configured headers, returning the server's result and draining the response stream so trailing RPC errors are propagated.CloseSessionthrough a newFlightSqlService::do_action_close_sessionhook. Session identification and resource cleanup remain the service implementor's responsibility; the default hook returnsUnimplemented.close-sessioncommand and session handling to the SQL server example for manual verification. The example prints the token at handshake so the same session can be closed twice using--token.Set/GetSessionOptions and other session-management messages are outside this PR's scope.
Are these changes tested?
Four new integration tests cover all defined close statuses and preservation of unknown values; missing or malformed responses and trailing RPC errors; server action discovery, malformed requests, header propagation, session removal and repeated closure; and the default unimplemented hook.
The arrow-flight unit, integration and example suites pass with
cli,flight-sql,tls-ring(141 tests). Manual verification against the example confirmed that closing the same token twice returnsClosed, thenNotFound, with corresponding server output. All-features example tests hit an existing conflict between the two TLS providers; the same failure was reproduced with the unchanged example from the base commit.Are there any significant user-facing changes?
This draft intentionally proposes a breaking API change and requires a major release.
FlightSqlServiceClient::close()changes fromResult<()>toResult<CloseSessionResult>and now sends a request instead of doing nothing. A transport, decoding or response-protocol failure remains anErr; a successfully decoded server result is returned asOk, leaving status handling to the caller.The return-type change preserves the information needed to decide whether to retry:
Closed: the close request is complete.Closing: closure is in progress; the caller may retry.NotCloseable: the caller should not retry.Keeping
Result<()>would either hide these distinctions or map valid server statuses into errors. In particular, treatingClosingas a generic protocol error would make it difficult for callers to distinguish a retryable close status from an actual protocol failure without inspecting error text. Returning the protocol result lets callers apply their own retry policy without adding another close method or imposing automatic retries. Existing callers that require a unit result need to adapt, even though the old method was a no-op. Servers without CloseSession support can now causeclose()to return an RPC error.There is also a server migration requirement:
CloseSessionis dispatched todo_action_close_sessionrather thando_action_fallback. Existing implementations that handle it in the fallback should move their session cleanup logic into the new hook; otherwise they will receive the defaultUnimplementederror. The library handles request decoding and response encoding. This migration is documented on the new hook.AI usage disclosure
Codex assisted with the implementation, tests, code review and this PR description. The changes were reviewed incrementally with the author, and the author manually verified the same-session close flow. Rust protobuf bindings were generated with the repository's generator.