-
Notifications
You must be signed in to change notification settings - Fork 601
[JDBC] NetworkTimeout #2522
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
[JDBC] NetworkTimeout #2522
Conversation
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
JDBC V1 CoverageCoverage Report
Class Coverage
|
Client V1 CoverageCoverage Report
Class Coverage
|
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.
Pull Request Overview
This PR implements JDBC network timeout functionality by adding support for Connection#abort
and Connection#setNetworkTimeout
methods. The implementation includes timeout detection, connection abortion logic, and proper propagation of socket timeout exceptions throughout the JDBC stack.
- Implements
Connection#abort
to properly close connections using an executor - Implements
Connection#setNetworkTimeout
with timeout caching and connection closure on timeout - Adds network timeout detection and handling across statement execution classes
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
ConnectionTest.java | Updates tests to verify abort and network timeout functionality instead of expecting unsupported feature exceptions |
JdbcUtils.java | Adds utility method for safe resource cleanup with logging |
WriterStatementImpl.java | Adds socket timeout detection and connection notification in write operations |
StatementImpl.java | Adds socket timeout detection and connection notification in query execution |
ResultSetImpl.java | Adds socket timeout detection and connection notification in result set iteration |
ConnectionImpl.java | Implements abort and network timeout methods with proper executor handling |
QuerySettings.java | Adds network timeout getter/setter methods for query configuration |
InsertSettings.java | Adds network timeout methods and merge functionality for insert operations |
Comments suppressed due to low confidence (2)
jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java:272
- Converting Long to intValue() can cause data loss if the timeout value exceeds Integer.MAX_VALUE. Consider using the Long value directly or adding validation.
return TRANSACTION_NONE;
jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java:282
- Converting Long to intValue() can cause data loss if the timeout value exceeds Integer.MAX_VALUE. Consider using the Long value directly or adding validation.
public void clearWarnings() throws SQLException {
} | ||
|
||
public Long getNetworkTimeout() { | ||
return (Long) rawSettings.get(ClientConfigProperties.SOCKET_OPERATION_TIMEOUT.getKey()); |
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.
Those methods are never used. Do you have any plans to add tests?
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.
yes, I'll test them.
// Some connection pools set timeout before calling Connection#close() to ensure that this operation will not hang | ||
// Socket timeout is propagated with QuerySettings this connection has. | ||
networkTimeoutExecutor = executor; | ||
defaultQuerySettings.setOption(ClientConfigProperties.SOCKET_OPERATION_TIMEOUT.getKey(), (long)milliseconds); |
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.
Why not use the new method setNetworkTimeout
|
Summary
Connection#abort
Connection#setNetworkTimeout
and logic that caches timeout exception and closes a connectionCloses #2413
Checklist
Delete items not relevant to your PR: