[Improvement] Avoid potential OOM in SessionPoolExample by replacing unbounded thread pool
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 54/100
Hướng nghiên cứu
Mở example/session/src/main/java/org/apache/iotdb/SessionPoolExample.java và kiểm tra phần khởi tạo ExecutorService quanh dòng 74. Xác nhận cách các hàng đợi của fixed thread pool hiện tại hoạt động, sau đó kiểm tra rằng ví dụ sử dụng dung lượng giới hạn và cung cấp backpressure mà không phụ thuộc vào hàng đợi không giới hạn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Search before asking
- I searched in the issues and found nothing similar.
Version
Master
Describe the bug and provide the minimal reproduce step
Description:
In example/session/src/main/java/org/apache/iotdb/SessionPoolExample.java, the ExecutorService is initialized using Executors.newFixedThreadPool(10) (Line 74).
Problem:
Executors.newFixedThreadPool uses an unbounded LinkedBlockingQueue (capacity: Integer.MAX_VALUE) by default. As this is an official example, users often copy-paste this code for production. In high-throughput write scenarios, if the production rate exceeds the consumption rate, tasks accumulate indefinitely in the queue, leading to OutOfMemoryError: Java heap space.
Code Location:
// org.apache.iotdb.SessionPoolExample.java
service = Executors.newFixedThreadPool(10); // Unbounded Queue risk
What did you expect to see?
Official examples should demonstrate best practices by using bounded queues to ensure system stability. The thread pool should provide backpressure (block or reject) when the queue is full, preventing memory exhaustion.
What did you see instead?
The example uses an unbounded queue pattern (UBSCQ), which creates a hidden memory leak risk for downstream users who adopt this code snippet.
Anything else?
Suggested Fix: Replace the factory method with a custom ThreadPoolExecutor using a bounded queue (e.g., ArrayBlockingQueue).
Proposed Code:
service = new ThreadPoolExecutor(
10, 10, 0L, TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<>(1000) // Bounded capacity
);
Are you willing to submit a PR?
- I'm willing to submit a PR!
- Ngôn ngữ chính
- Java
- Star
- 6.4k
- Fork
- 1.2k
- Merge trung bình
- 1 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 152
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/iotdb
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
apache/iotdb#18655 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
IoTDB Edge: stop-edge.sh does not stop its own process when IOTDB_HOME is set, and reports successĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] 执行start-all.sh后无法启动集群问题Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] findColumn throws NullPointerException instead of SQLException for an unknown column nameĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
checkstyle/checkstyle#21755 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
github/copilot-sdk#2782 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Make docs website more visibleĐang mởdocumentation Good for newcomer quick win
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CodeForPhilly/benefit-decision-toolkit#519 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area-deployment triage:bot-seen triage:needs-human
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/aspire#20533 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày