[Improvement] Avoid potential OOM in SessionPoolExample by replacing unbounded thread pool
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 54/100
調査の方向性
example/session/src/main/java/org/apache/iotdb/SessionPoolExample.java を開き、74 行目付近の ExecutorService の初期化を確認してください。現在の固定スレッドプールのキューがどのように機能するかを確認し、そのうえで、例が有界容量を使用し、無制限キューに依存せずにバックプレッシャーを提供していることを検証してください。
索引モデルが issue の本文から書いたものです。
説明
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!
- 主要言語
- Java
- スター
- 6.4k
- フォーク
- 1.2k
- 平均マージ
- 1日 20時間
- マージ済み PR(30日)
- 137
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/iotdb のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/iotdb#18655 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
IoTDB Edge: stop-edge.sh does not stop its own process when IOTDB_HOME is set, and reports successオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
[Bug] findColumn throws NullPointerException instead of SQLException for an unknown column nameオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
redhat-developer/intellij-quarkus#1626 ·
-
Type/Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
wso2/product-integrator-mi#5061 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
quarkiverse/quarkus-roq#1277 ·
メンテナーはふだん 1 日以内に返信
-
Typos in page footerオープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
apache/logging-site#48 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/maven-surefire#3496 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信