[Bug] File descriptor leak in CLI CSV import: CSVParser from readCsvFile is never closed
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Bắt đầu bằng việc đọc AbstractDataTool.readCsvFile và các điểm vào import được nêu tên: ImportData.importFromSingleFile, ImportDataTree.importFromCsvFile, ImportDataTable.importFromCsvFile và ImportSchemaTree.importSchemaFromCsvFile. Tái hiện vấn đề với nhiều tệp CSV nhỏ dưới một ulimit thấp, sau đó xác minh rằng mọi parser đều được đóng khi hoàn tất bình thường và khi return sớm, mà không làm cạn kiệt các bộ mô tả tệp.
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 (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!
- 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
Hướng dẫn đóng góp
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
-
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
-
[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
-
[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
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Issue tương tự
-
area-deployment area-integrations triage:bot-seen
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 86/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
apache/flink-agents#1156 ·
-
[source-shopify] FAILED bulk operation without partialDataUrl is silently treated as successful Đang mởarea/connectors autoteam community connectors/source/shopify needs-triage team/use type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100