apache / apache/arrow-java

[JAVA] Leak in JdbcToArrowUtils

Đang mở
#408 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Type: bug
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ả

`JdbcToArrowUtils::updateVector(VarCharVector, String, boolean, int)` does not release the memory that it allocates for the `NullableVarCharHolder`. This can be verified by changing the first lines of `JdbcToArrowTest::testJdbcToArrowValues()` to the following:
```java

RootAllocator allocator = new RootAllocator(Integer.MAX_VALUE);
VectorSchemaRoot root = JdbcToArrow.sqlToArrow(conn, table.getQuery(), allocator, Calendar.getInstance());
testDataSets(root);
root.close();
assertEquals(allocator.getAllocatedMemory(), 0);
```
 

The leak can be fixed by closing the buffer in `updateVector`. However, I would propose to not use the `NullableVarCharHolder` in the first place because it creates an unnecessary copy of the string. Instead, I would use `BaseVariableWidthVector::setSafe(int index, byte[] value)` and `BaseVariableWidthVector::setNull(int index)` directly.

In addition, I would propose to check for leaks in JdbcToArrowTest.

I am willing to create a patch, so please let me know what approach is preferred.

**Reporter**: [Johannes Luong](https://issues.apache.org/jira/browse/ARROW-5536) / @jmaschad

**Note**: *This issue was originally created as [ARROW-5536](https://issues.apache.org/jira/browse/ARROW-5536). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu tại JdbcToArrowUtils::updateVector(VarCharVector, String, boolean, int) và kiểm tra cách NullableVarCharHolder cấp phát bộ đệm của nó. Xem lại JdbcToArrowTest::testJdbcToArrowValues() và thêm assertion về bộ nhớ của allocator được hiển thị trong issue; công việc hoàn tất khi test chạy qua với lượng bộ nhớ đã cấp phát bằng không sau khi đóng root.

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
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.