[FlightSQL] Statement.execute(String) can leak server prepared-statement handles when reused
- Ngôn ngữ chính
- Java
- Star
- 94
- Fork
- 152
- Merge trung bình
- 3 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 11
Mô tả
### 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
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu từ triển khai JDBC của Flight SQL cho Statement.execute(String) và theo dõi cách các prepared-statement handles được thay thế và đóng; issue không nêu tên file hay test nào. Tái hiện vòng lặp với một máy chủ Flight SQL có trạng thái, sau đó xác minh rằng mỗi handle trước đó được giải phóng trước khi handle tiếp theo được theo dõi và Statement.close vẫn dọn dẹp handle cuối cùng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java
- Lĩnh vực
- databases
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 55/100