Skip to content

Conversation

@ennuite
Copy link
Contributor

@ennuite ennuite commented Nov 18, 2025

What's Changed

When using the Flight SQL JDBC driver with connection pooling and a catalog parameter, ArrowFlightSqlClientHandler.close() performs a CloseSession RPC that can fail during gRPC channel shutdown.

These transient failures (UNAVAILABLE or INTERNAL with "Connection closed after GOAWAY") cause noisy errors in pooling frameworks like Apache Commons DBCP.

With this PR these exceptions will instead be suppressed and logged, following the procedure that was used for ARROW-17785

Are these changes tested?

Yes

Closes #863

Vando Pereira and others added 5 commits November 14, 2025 19:48
…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.
…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
@github-actions
Copy link

Thank you for opening a pull request!

Please label the PR with one or more of:

  • bug-fix
  • chore
  • dependencies
  • documentation
  • enhancement

Also, add the 'breaking-change' label if appropriate.

See CONTRIBUTING.md for details.

@ennuite ennuite marked this pull request as ready for review November 18, 2025 13:55
@ennuite ennuite changed the title GH-863: [JDBC] Suppress benign exceptions from gRPC layer GH-863: [JDBC] Suppress benign exceptions from gRPC layer on ArrowFlightSqlClientHandler#close Nov 18, 2025
@ennuite ennuite marked this pull request as draft November 18, 2025 14:14
@ennuite
Copy link
Contributor Author

ennuite commented Nov 18, 2025

This PR is based on https://github.com/apache/arrow-java/pull/864/files, @vandop asked me to take it over from him.

I simplified the tests. I don't think this merits a full integration test with shutting down a server because all the logic is inside a single method.

About the logging level: for the original issue at https://github.com/apache/arrow/pull/14210/files the log level was set to warn, and in Vando's PR @lidavidm asked for the log level to be debug. It's not clear to me the reason for the discrepancy, and I put it as info.

@ennuite ennuite marked this pull request as ready for review November 18, 2025 15:11
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.

ArrowFlightSqlClientHandler.close() performs a CloseSession RPC that can fail during gRPC channel shutdown - similar to ARROW-17785

1 participant