Repository navigation
GH-1502: [JDBC] Close the server session on Connection#close without a catalog - #1504
Open
AbhishekPathania wants to merge 3 commits into
Open
AbhishekPathania wants to merge 3 commits into
AbhishekPathania wants to merge 3 commits into
Conversation
AbhishekPathania
requested review from
jbonofre,
laurentgo,
lidavidm and
wgtmac
as code owners
November 18, 2026 14:11
This comment has been minimized.
This comment has been minimized.
AbhishekPathania
marked this pull request as draft
November 18, 2026 14:15
AbhishekPathania
marked this pull request as ready for review
November 18, 2026 15:28
AbhishekPathania
force-pushed
the
jdbc-close-session-without-catalog
branch
2 times, most recently
from
November 19, 2026 11:11
384b190 to
84c8253
Compare
jbonofre
requested changes
Nov 19, 2026
| fre, "Failed to close Flight SQL session.", "closing Flight SQL session"); | ||
| } else { | ||
| // Without a catalog the driver never asked for a session; the server may not support them. | ||
| logSuppressedCloseException(fre, "closing Flight SQL session"); |
Member
There was a problem hiding this comment.
This suppresses every FlightRuntimeException when no catalog is configured, including failures such as UNAVAILABLE or UNAUTHENTICATED. In those cases Connection.close() succeeds even though the server session may remain open.
Could we suppress only statuses indicating that the server does not support session catalog, and propagate other failures as we do when a catalog is configured?
Contributor
Author
There was a problem hiding this comment.
Thanks, fair point. I narrowed it. Without a catalog, close now only ignores statuses that mean there's no session to close:
UNIMPLEMENTED: servers without CloseSession (the Java, Go and C++ defaults)INVALID_ARGUMENT: servers that don't know the action, like all Rust servers today (https://github.com/apache/arrow-rs/blob/9951b625879a19844ecd0b2dd352347a87ea26dd/arrow-flight/src/sql/server.rs#L451) and older Java/Go onesNOT_FOUND:ServerSessionMiddlewarewhen no session was createdUNAUTHENTICATED: the client isn't (or is no longer) authenticated, so there's no session. Without it, existing tests that connect without credentials (e.g.ConnectionTest#testGetBasicClientNoAuthShouldOpenConnection) fail on close.
Everything else goes through the catalog path.
…nt handlers Endpoint handlers are built from a copy of the connection's Builder and authenticate with the connection's credentials. On a server that keys sessions by bearer token, a CloseSession from a failed endpoint fetch would end the connection's own session. ADBC's Flight SQL driver likewise never closes sessions from its endpoint clients.
AbhishekPathania
force-pushed
the
jdbc-close-session-without-catalog
branch
from
November 19, 2026 15:13
84c8253 to
bc7f091
Compare
…on without a catalog
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.
What's Changed
Connection#closenow sendsCloseSessioneven when nocatalogwas set, so servers that create a session per connection can free it right away.UNIMPLEMENTED,INVALID_ARGUMENT,NOT_FOUND,UNAUTHENTICATED) are logged at debug and ignored. Other errors are handled as with a catalog.closecannot hang on an unresponsive server.FlightClient#closealready waits up to 5 seconds for the channel to shut down.CloseSessionthrows.getStreamsbuilds for other endpoint locations never sendCloseSession. They authenticate with the connection's credentials, so on a server that keys sessions by bearer token, closing one after a failed fetch would end the connection's own session. ADBC's driver also closes only the main client's session.This matches ADBC's Flight SQL driver, which always sends
CloseSessionon close.The code and tests were drafted with an AI assistant (Claude). I reviewed every change and also ran it against our own Flight SQL server, where 25 reconnects left 25 sessions open before this change and none after.
Closes #1502.