I'm experiencing persistent timeout issues when connecting ClickHouse (v25.2.2.39) to SQL Server through the ClickHouse JDBC Bridge (v2.1.0).
Simple queries work fine: SELECT * FROM jdbc('DWH', 'SELECT 1 AS first;')
Complex queries with large result sets work fine: SELECT * FROM jdbc('DWH', 'SELECT TOP 10000 a.* FROM sys.objects a JOIN sys.columns b ON a.object_id = b.object_id')
Any query that takes more than a 30 seconds to execute consistently fails with: VertxException: Connection was closed
Error from logs:
Apr 29, 2025 11:24:22 PM com.clickhouse.jdbcbridge.core.ResponseWriter write
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: WARNING: Still have at least 24 bytes in buffer
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: Apr 29, 2025 11:24:22 PM com.clickhouse.jdbcbridge.JdbcBridgeVerticle errorHandler
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: SEVERE: Failed to respond
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: java.lang.IllegalStateException: Response stream was closed
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: at com.clickhouse.jdbcbridge.core.ResponseWriter.write(ResponseWriter.java:68)
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: at com.clickhouse.jdbcbridge.core.DataTableReader.process(DataTableReader.java:187)
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: at com.clickhouse.jdbcbridge.impl.JdbcDataSource.writeQueryResult(JdbcDataSource.java:720)
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: at com.clickhouse.jdbcbridge.core.NamedDataSource.executeQuery(NamedDataSource.java:552)
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: at com.clickhouse.jdbcbridge.JdbcBridgeVerticle.handleQuery(JdbcBridgeVerticle.java:492)
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: at com.clickhouse.jdbcbridge.internal.vertx.ext.web.impl.BlockingHandlerDecorator.lambda$handle$0(BlockingHandlerDecorator.java:48)
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: at com.clickhouse.jdbcbridge.internal.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:313)
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: at com.clickhouse.jdbcbridge.internal.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
Apr 29 23:24:22 dwh-unapp-01 java[3575064]: at java.base/java.lang.Thread.run(Thread.java:1583)
What I've tried:
Increased timeout values in JDBC Bridge configuration:
"DWH": {
"jdbcUrl": "jdbc:sqlserver://server:1433;encrypt=true;trustServerCertificate=true;queryTimeout=600;socketTimeout=600000;loginTimeout=60;...",
"settings": {
"vertx.workerPoolSize": 20,
"vertx.blockingThreadCheckInterval": 100000,
"vertx.maxWorkerExecuteTime": 600000,
"vertx.maxWorkerExecuteTimeUnit": "MILLISECONDS"
},
"queryTimeout": 600000,
"writeTimeout": 600000
Commented out the timeout check in ResponseWriter.java that was throwing "Abort due to timeout" exceptions
public void write(ByteBuffer buffer) {
if (this.response.closed() || this.response.ended()) {
if (buffer != null && buffer.length() > 0) {
log.warn("Still have at least {} bytes in buffer", buffer.length());
}
throw new IllegalStateException("Response stream was closed");
}
// Commented out: if (this.timeout > 0 && ((System.currentTimeMillis() - this.startTime) > this.timeout)) {
// throw new IllegalStateException("Abort due to timeout");
// }
this.response.write(buffer.unwrap());
}
Added ClickHouse HTTP timeouts:
<profiles>
<default>
<http_connection_timeout>0</http_connection_timeout>
<http_receive_timeout>0</http_receive_timeout>
<max_execution_time>600</max_execution_time>
<http_max_tries>5</http_max_tries>
<http_retry_initial_backoff_ms>100</http_retry_initial_backoff_ms>
<http_retry_max_backoff_ms>10000</http_retry_max_backoff_ms>
<http_send_timeout>600</http_send_timeout>
<receive_timeout>600</receive_timeout>
<send_timeout>600</send_timeout>
</default>
</profiles>
Despite all these changes, I still consistently get "Connection was closed" errors. The logs show the connection is being closed by the Vertx HTTP server or client, but I can't figure out what's causing it. Looking at the error stack trace, it seems the error is occurring in JdbcBridgeVerticle.lambda$responseHandlers$3, which suggests it's happening in a response handler callback. What else should I try?
- Is there a hardcoded timeout in Vertx's HTTP implementation that I'm missing?
- Could the Apache HTTP Client settings make a difference?
- Are there any known issues with the JDBC bridge and long-running queries?
Any insight would be greatly appreciated!
Environment:
- ClickHouse version: 25.2.2.39
- ClickHouse JDBC Bridge: 2.1.0
- SQL Server: Microsoft SQL Server 2019
- Java: OpenJDK 21.0.6
- Operating System: Ubuntu 24.04