apache / apache/druid

Potential resource leaks in IntermediateRowParsingReader.intermediateRowIterator()

Open
#9,867 0 comments 0 reactions 0 assignees View on GitHub
Area - Batch Ingestion Bug
Dominant language
Java
Stars
14.1k
Forks
3.8k
Avg merge
2d 58m
Merged PRs (30d)
233

Description

### Affected Version

All versions since 0.17.0

### Description

`IntermediateRowParsingReader.intermediateRowIterator()` returns a `CloseableIterator` which cleans up underlying resources when the iterator is closed. Currently, many implementations such as `OrcReader` or `ParquetReader` registers resources on a `Closer` and passes it to the `CloseableIterator`. This usually works fine, but if some exception occurred before returning `CloseableIterator`, the resources registered on the closer would not be cleaned up. This will be fine with middleManagers, but not with Indexers.

The fix would be catching any exceptions before returning the iterator and closing the closer in `intermediateRowIterator()`.

Contributor guide

Open the contributing guide

Research direction

Start at IntermediateRowParsingReader.intermediateRowIterator() and compare how OrcReader and ParquetReader register resources on a Closer. Trace the exception path before the CloseableIterator is returned. Done means exceptions during iterator creation close the Closer and do not leave registered resources open.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.