[Bug] File descriptor leak in CLI CSV import: CSVParser from readCsvFile is never closed
維護者通常 1 天內回覆
評估
研究方向
先閱讀 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 天 11 小時
- 30 天內合併 PR
- 182
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
apache/iotdb 的其他 Issue
-
[Bug] sbin/replace-conf-from-env.sh word-splits the whole environment and corrupts iotdb-system.properties可能已有人在做 @anishmehta24 於 28 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
apache/iotdb#18655 · 1 個 reaction ·
維護者通常 1 天內回覆
-
IoTDB Edge: stop-edge.sh does not stop its own process when IOTDB_HOME is set, and reports success可能已有人在做 @PDGGK 於 48 天前認領。 未關閉
難度 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可能已有人在做 @PDGGK 於 90 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
[Bug] ResultSetMetaData.getCatalogName throws IndexOutOfBoundsException instead of SQLException for out-of-range columns可能已有人在做 @PDGGK 於 92 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
相似的 Issue
-
NullPointerException when a `DeserializationProblemHandler` returns `null` for `byte[]` (single value unwrapped) and `char[]` elements可能已有人在做 @Marti2203 今天認領。 未關閉
難度 2/5 半天 新手友好度 88/100
FasterXML/jackson-databind#6300 ·
維護者通常 1 天內回覆
-
content good first issue
難度 1/5 1 小時以內 新手友好度 95/100
cpinitiative/usaco-guide#6699 ·
維護者通常 1 天內回覆
-
BC remittance upload: a claim MSP refused (S03) is saved with a blank status instead of refused (F)未關閉type: bug
難度 2/5 1-3 小時 新手友好度 88/100
carlos-emr/carlos#4933 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 82/100
apache/rocketmq-dashboard#6925 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
Vakore/ZappierGames#147 ·