-
Notifications
You must be signed in to change notification settings - Fork 87
GH-863: [Flight SQL][JDBC] Suppress benign CloseSession errors when catalog is set #864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…hen catalog is set This change addresses race conditions during gRPC channel shutdown that occur when using connection pooling with catalog parameters. The CloseSession RPC can fail with UNAVAILABLE or 'Connection closed after GOAWAY' errors during normal connection cleanup. Key improvements: - Refactored duplicate exception handling code into reusable helper methods - Added comprehensive error suppression for both AutoCloseable cleanup and CloseSession - Follows the established ARROW-17785 pattern from PreparedStatement.close() - Improved logging with context-aware debug/info messages - Fixed typo in existing error suppression logging The refactoring eliminates code duplication while maintaining identical functionality and improving maintainability.
ARROW-17785: [Flight SQL][JDBC] Suppress benign CloseSession errors when catalog is set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to unit test this?
…on error suppression Add unit and integration tests for the error suppression functionality in ArrowFlightSqlClientHandler: - ArrowFlightSqlClientHandlerTest: 18 unit tests covering error detection, logging, and exception handling logic using Mockito and reflection - ArrowFlightSqlClientHandlerIntegrationTest: 4 integration tests with real FlightServer to validate error suppression in realistic scenarios Tests verify that benign gRPC shutdown errors (UNAVAILABLE and INTERNAL with GOAWAY) are properly suppressed while genuine failures are correctly propagated as exceptions.
…reliability This commit addresses bugs introduced in the error suppression implementation: 1. Fixed NullPointerException in isBenignCloseException() when FlightRuntimeException.getMessage() returns null. Added null check before calling contains() on the message string. 2. Fixed unit test setup to avoid attempting real server connections during test initialization. Tests now use reflection to test private methods without requiring actual network connections. 3. Fixed Mockito unnecessary stubbing warnings by making all mock objects lenient, allowing tests to create comprehensive mocks without triggering warnings when not all stubbings are used. 4. Simplified integration tests to focus on testable scenarios. Removed tests that required mocking gRPC service methods (closeSession) which are not routed through FlightProducer, making them difficult to test in isolation. Test Results: - 21 tests total (15 unit + 1 integration + 5 builder tests) - All tests passing with 0 failures and 0 errors - Comprehensive coverage of error suppression logic via reflection-based unit tests
Thank you for opening a pull request! Please label the PR with one or more of:
Also, add the 'breaking-change' label if appropriate. See CONTRIBUTING.md for details. |
I've added some tests now, trying to follow the existing patterns. The robot is also checking for a label, which I assume someone with write permission has to add it, right? This would be a bug-fix from my perspective. thanks for looking into it |
fixes #863
Rationale for this change
When using the Flight SQL JDBC driver with connection pooling and a catalog parameter,
ArrowFlightSqlClientHandler.close()
performs aCloseSession
RPC that can fail during gRPC channel shutdown. These transient failures (UNAVAILABLE
orINTERNAL
with "Connection closed after GOAWAY") bubble up asSQLException
and cause noisy errors in pooling frameworks like Apache Commons DBCP.What changes are included in this PR?
Core Changes
ArrowFlightSqlClientHandler.close()
for both:CloseSession
RPC callsAutoCloseable
resource cleanupisBenignCloseException()
,logSuppressedCloseException()
,handleBenignCloseException()
Error Suppression Logic
Suppress only these specific transient shutdown conditions:
FlightStatusCode.UNAVAILABLE
FlightStatusCode.INTERNAL
with message containing "Connection closed after GOAWAY"Logging Improvements
Are there any user-facing changes?
Yes - Improved user experience:
SQLException
)How was this patch tested?
Integration Testing
data.dremio.cloud:443
)jdbc:arrow-flight-sql://data.dremio.cloud:443/?token=<PAT>&catalog=<PROJECT_ID>
Validation Steps
UNAVAILABLE
/INTERNAL("Connection closed after GOAWAY")
errors during connection closeSQLException