[Bug] File descriptor leak in CLI CSV import: CSVParser from readCsvFile is never closed
まだ誰も着手していません。
評価
調査の方向性
まず AbstractDataTool.readCsvFile と、指定されたインポートエントリポイントである ImportData.importFromSingleFile、ImportDataTree.importFromCsvFile、ImportDataTable.importFromCsvFile、ImportSchemaTree.importSchemaFromCsvFile を読みます。低い ulimit の下で多数の小さな CSV ファイルを使って問題を再現し、その後、正常終了時と早期 return の場合のどちらでも、ファイルディスクリプタを使い果たすことなくすべてのパーサーがクローズされることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Search before asking
- I searched in the issues and found nothing similar.
Version
master (2.0.x). The affected code is also present in released 2.0.x versions.
Describe the bug and provide the minimal reproduce step
AbstractDataTool.readCsvFile(String) builds a CSVParser over new InputStreamReader(new FileInputStream(path)) and returns it. The CSVParser owns that FileInputStream, but the CLI import code paths that call it never close the returned parser — it is assigned to a local inside a plain try { ... } block (no try-with-resources, no finally). Every imported file therefore leaks its file descriptor, and the early returns for an empty file or an invalid header leak it immediately, because the parser is opened before those checks run.
Affected call sites (current master, also present in released 2.0.x):
iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportData.java—importFromSingleFileiotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTree.java—importFromCsvFileiotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTable.java—importFromCsvFileiotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTree.java—importSchemaFromCsvFile(this class has its own copy ofreadCsvFile)
Minimal reproduce step:
- Create a directory containing a large number of small CSV files — more than the process open-file limit (for example a few thousand files under
ulimit -n 1024). - Run the CLI data import over that directory.
- The import fails partway through with
Too many open files. (A single import already leaks one descriptor; it is simply not fatal until enough accumulate.)
What did you expect to see?
Each CSVParser (and the FileInputStream it wraps) is closed after the file is processed, on every exit path — including the empty-file / invalid-header early returns. Importing a large directory of CSV files should not exhaust the process's file descriptors.
What did you see instead?
The CSVParser returned by readCsvFile is never closed, so its underlying FileInputStream stays open. Importing a directory with enough CSV files leaks descriptors until the import fails with Too many open files.
Anything else?
The record Stream is fully consumed inside the same block before the method returns, so consuming each parser in a try-with-resources (closing it on scope exit) is safe.
Are you willing to submit a PR?
- I'm willing to submit a PR!
- 主要言語
- Java
- スター
- 6.4k
- フォーク
- 1.2k
- 平均マージ
- 1日 17時間
- マージ済み PR(30日)
- 152
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/iotdb のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
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
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
[Bug] findColumn throws NullPointerException instead of SQLException for an unknown column name オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
似ている issue
-
area-deployment area-integrations triage:bot-seen
難易度 2/5 半日 初心者へのやさしさ 86/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
apache/flink-agents#1156 ·
-
[source-shopify] FAILED bulk operation without partialDataUrl is silently treated as successful オープンarea/connectors autoteam community connectors/source/shopify needs-triage team/use type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100