[Bug] File descriptor leak in CLI CSV import: CSVParser from readCsvFile is never closed
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 76/100
Direção de pesquisa
Comece lendo AbstractDataTool.readCsvFile e os pontos de entrada de importação nomeados: ImportData.importFromSingleFile, ImportDataTree.importFromCsvFile, ImportDataTable.importFromCsvFile e ImportSchemaTree.importSchemaFromCsvFile. Reproduza o problema com muitos arquivos CSV pequenos sob um ulimit baixo e, em seguida, verifique se todo parser é fechado na conclusão normal e em retornos antecipados, sem esgotar os descritores de arquivo.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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!
- Linguagem predominante
- Java
- Estrelas
- 6.4k
- Forks
- 1.2k
- Merge médio
- 1d 17h
- PRs com merge (30d)
- 152
Preparar o ambiente
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de apache/iotdb
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
apache/iotdb#18655 · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
IoTDB Edge: stop-edge.sh does not stop its own process when IOTDB_HOME is set, and reports successAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
[Bug] findColumn throws NullPointerException instead of SQLException for an unknown column nameAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
Todas as issues de apache/iotdb
Issues semelhantes
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
ci-failure-cause test-failure
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
nextcloud/notes-android#3367 ·
Mantenedores costumam responder em até 1 dia
-
:wave: team-triage a:chore in:isolated-projects in:kotlin-dsl
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia