Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Java] VectorUnloader has multiple memory leak issues

Đang mở
#1,234 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
62/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
java
Lĩnh vực
data

Hướng nghiên cứu

Bắt đầu với lớp VectorUnloader, tập trung vào getRecordBatch() và appendNodes(), đặc biệt là các luồng retain(), compress() và xử lý đệ quy các nút con được mô tả trong issue. Xác minh rằng các lỗi tại mỗi vị trí đều giải phóng mọi ArrowBuf được giữ lại, bao gồm cả các buffer từ những lần lặp trước, và xác nhận rằng việc tuần tự hóa record batch thông thường vẫn hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Type: bug
Describe the bug, including details regarding any error messages, version, and platform.
Problem Description

The VectorUnloader class has serious memory leak issues when serializing Vector data. Any exception thrown during the process will cause previously retained ArrowBuf instances to never be released.
Root Cause
ArrowBuf uses reference counting for memory management. After calling retain(), a corresponding release() must be called to free the buffer. The code has exception-safety defects in multiple locations:


Bug 1: OOM during compression causes leak
Location: appendNodes() method, around line 75
buf.getReferenceManager().retain();
buffers.add(codec.compress(vector.getAllocator(), buf)); // OOM here causes leak
Problem: If codec.compress() throws OutOfMemoryError, retain() has already been called but buffers.add() never executes, making the ArrowBuf unreleasable.

Bug 2: Compression failure in loop causes partial leak
Location: appendNodes() method, around lines 78-85
for (ArrowBuf buf : fieldBuffers) {
    buf.getReferenceManager().retain();
    buffers.add(codec.compress(vector.getAllocator(), buf)); // Any failure leaks all previously retained buffers
}
Problem: Any compression failure in the loop causes all previously retained buffers to leak.

Bug 3: Exception during recursive child vector processing causes leak
Location: appendNodes() method, around lines 87-89
for (FieldVector child : vector.getChildrenFromFields()) {
    appendNodes(child, nodes, buffers, variadicBufferCounts); // Exception here leaks buffers from current level
}
Problem: An exception during recursive child processing prevents release of buffers already retained at the current level.

Bug 4: Iteration failure in top-level loop causes cumulative leaks
Location: getRecordBatch() method, around lines 53-58
for (FieldVector vector : root.getFieldVectors()) {
    appendNodes(vector, nodes, buffers, variadicBufferCounts); // Any failure leaks all previously retained buffers
}
Problem: Each iteration retains buffers, and any failure causes cumulative leaks of all previously retained buffers. This is an accumulated leak.

Impact
  • All code using VectorUnloader.getRecordBatch()
  • Leak probability increases significantly when processing large datasets or when compressor runs low on memory
  • Leaked ArrowBuf instances persist until process termination
    Suggested Fix
  1. Use try-finally to ensure release() is called even when exceptions occur
  2. Or add buffers to the list before calling retain() and compress()
  3. Use transactional error handling for the entire getRecordBatch() operation, rolling back all buffers on failure
Ngôn ngữ chính
Java
Star
95
Fork
154
Merge trung bình
2 ngày 10 giờ
Pull request đã merge (30 ngày)
11

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

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/arrow-java

Tất cả issue của apache/arrow-java

Issue tương tự

Thêm issue về Java

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.