ClickHouse / ClickHouse/clickhouse-java

PreparedStatement.setQueryTimeout() not honored in ClickHouse JDBC driver (version 0.9.1-all)

オープン
#2,637 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug investigating jdbc-v2
主要言語
Java
スター
1.6k
フォーク
636
平均マージ
2日 23時間
マージ済み PR(30日)
29

説明

**Description**

When setQueryTimeout() is applied to a PreparedStatement, the timeout is not honored during query execution.
Even if the query exceeds the configured timeout value, it continues to run until completion or manual termination.

This behavior is observed with the ClickHouse JDBC driver 0.9.1 (classifier: all).

**Steps to Reproduce**

1. Configure a ClickHouse JDBC connection using version 0.9.1-all.
2. Create a long-running query (e.g., SELECT sleep(3)).
3. Use PreparedStatement.setQueryTimeout(1) to set a 1-second timeout.
4. Execute the query.

**Error Log or Exception StackTrace**

No exception or timeout is thrown.
The query runs to completion, ignoring the configured timeout.

**Expected Behaviour**
The query should stop execution after the specified timeout period and throw an SQLTimeoutException.

**Code Example**
```

try (Connection connection = DriverManager.getConnection(url, user, password)) {
String sql = "SELECT sleep(3)"; // intentionally long query
try (PreparedStatement stmt = connection.prepareStatement(sql)) {
stmt.setQueryTimeout(1); // set timeout to 1 seconds
long start = System.currentTimeMillis();
stmt.executeQuery();
long end = System.currentTimeMillis();
System.out.println("Query completed in " + (end - start) / 1000 + " seconds");
}
}catch (SQLTimeoutException te) {
System.err.println("Query timed out: " + te.getMessage());
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
e.printStackTrace();
}
```

Actual Result: The query runs for approximately 3 seconds.
Expected Result: The query should terminate after around 1 seconds and throw an SQLTimeoutException.

### Configuration

#### Client Configuration
```

com.clickhouse
clickhouse-jdbc
0.9.1
all

```
#### Environment
* [ ] Cloud
Client version: java jdbc v2 0.9.2 and 0.9.1
Language version: Java 17
OS:

#### ClickHouse Server
* ClickHouse Server version:
* ClickHouse Server non-default settings, if any:
* `CREATE TABLE` statements for tables involved:
* Sample data for all these tables, use [clickhouse-obfuscator](https://github.com/ClickHouse/ClickHouse/blob/master/programs/obfuscator/Obfuscator.cpp#L42-L80) if necessary

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

JDBC PreparedStatement.setQueryTimeout() のエントリポイントから開始し、Java 17 と 0.9.1-all ドライバーを使用して SELECT sleep(3) で問題を再現します。期待される動作に記載されているとおり、1 秒のタイムアウトによって実行が中断され、SQLTimeoutException が発生することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
databases
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。