[FlightSQL] Statement.execute(String) can leak server prepared-statement handles when reused
- 主要言語
- Java
- スター
- 94
- フォーク
- 152
- 平均マージ
- 3日 16時間
- マージ済み PR(30日)
- 11
説明
### Describe the bug, including details regarding any error messages, version, and platform.
When reusing the same JDBC Statement and calling execute(String) multiple times, the Flight SQL JDBC path creates a new prepared statement on each call, but previous prepared handles are not closed before being replaced in client tracking state.
This means only the latest handle is guaranteed to be closed when the statement is closed. On stateful Flight SQL servers, this can leak server-side resources associated with older handles.
Repro
```
try (Connection connection = DriverManager.getConnection(jdbcUrl, properties);
Statement statement = connection.createStatement()) {
for (int i = 1; i <= n; i++) {
String sql = "SELECT " + i;
boolean isResultSet = statement.execute(sql);
if (isResultSet) {
try (ResultSet rs = statement.getResultSet()) {
while (rs.next()) { /* consume */ }
}
}
}
}
```
Raised in https://github.com/apache/arrow-java/pull/1090#discussion_r3132344585
コントリビューションガイド
調査の方向性
Flight SQL の JDBC 実装にある Statement.execute(String) から開始し、prepared-statement handles がどのように置き換えられ、閉じられるかを追跡してください。この issue ではファイルもテストも指定されていません。状態を保持する Flight SQL サーバーに対してループを再現し、その後、次の handle が追跡される前に各以前の handle が解放されること、また Statement.close が最後の handle を引き続きクリーンアップすることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- databases
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 55/100