Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[Bug] File descriptor leak in CLI CSV import: CSVParser from readCsvFile is never closed

Abierto
#18,237 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
java
Área
cli

Línea de trabajo

Empieza leyendo AbstractDataTool.readCsvFile y los puntos de entrada de importación indicados: ImportData.importFromSingleFile, ImportDataTree.importFromCsvFile, ImportDataTable.importFromCsvFile e ImportSchemaTree.importSchemaFromCsvFile. Reproduce el problema con muchos archivos CSV pequeños bajo un ulimit bajo y, después, verifica que cada analizador se cierre al completarse normalmente y al producirse retornos anticipados, sin agotar los descriptores de archivo.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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 — importFromSingleFile
  • iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTree.java — importFromCsvFile
  • iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ImportDataTable.java — importFromCsvFile
  • iotdb-client/cli/src/main/java/org/apache/iotdb/tool/schema/ImportSchemaTree.java — importSchemaFromCsvFile (this class has its own copy of readCsvFile)

Minimal reproduce step:

  1. 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).
  2. Run the CLI data import over that directory.
  3. 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!
Lenguaje dominante
Java
Estrellas
6.4k
Forks
1.2k
Merge medio
1 d 17 h
PR fusionados (30 d)
152

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/iotdb

Todos los issues de apache/iotdb

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.