[Bug] File descriptor leak in CLI CSV import: CSVParser from readCsvFile is never closed
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 76/100
Piste de recherche
Commencez par lire AbstractDataTool.readCsvFile et les points d’entrée d’importation indiqués : ImportData.importFromSingleFile, ImportDataTree.importFromCsvFile, ImportDataTable.importFromCsvFile et ImportSchemaTree.importSchemaFromCsvFile. Reproduisez le problème avec de nombreux petits fichiers CSV sous un ulimit faible, puis vérifiez que chaque analyseur est fermé en cas de fin normale et de retours anticipés, sans épuiser les descripteurs de fichiers.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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!
- Langage dominant
- Java
- Étoiles
- 6.4k
- Forks
- 1.2k
- Merge moyen
- 1 j 17 h
- PR mergées (30 j)
- 152
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de apache/iotdb
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
IoTDB Edge: stop-edge.sh does not stop its own process when IOTDB_HOME is set, and reports success Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
[Bug] 执行start-all.sh后无法启动集群问题 Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
[Bug] findColumn throws NullPointerException instead of SQLException for an unknown column name Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Toutes les issues de apache/iotdb
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
HL7/fhir-ig-publisher#1375 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
-
Flaky: a relaunched catch-up replay can still report catching up right after its marker is written Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
johanhaleby/occurrent#1134 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
objectionary/jeo-maven-plugin#1811 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100