cshuo opened a new issue, #20022: URL: https://github.com/apache/hudi/issues/20022
### Bug Description **What happened:** `SpillableLsmRecordIterator` can leave a local spill file behind when spilling succeeds but closing the source iterator throws a `RuntimeException`. The constructor writes the spill file, then calls `closeSourceIterator()` in its `finally` block. In this case `spillFailure` is null, and the source-close exception is propagated without deleting the completed spill file. Construction fails, so the outer reader never receives the spill iterator and cannot call its `close()` method. The cleanup in `spill()` only handles failures during spilling and does not cover this later failure. **What you expected:** Delete the spill file when source closure prevents construction from completing. Preserve the source-close exception as the primary failure and attach any spill-file deletion failure as a suppressed exception. **Steps to reproduce:** 1. Create a source `ClosableIterator<BufferedRecord<String>>` whose records can be drained successfully but whose `close()` throws a `RuntimeException`. 2. Construct `SpillableLsmRecordIterator` with that source and a writable temporary spill directory. An empty source is sufficient to reproduce the issue. 3. Catch the constructor exception and inspect the spill directory: the `hudi-lsm-*.spill` file remains even though no spill iterator was returned. This was reproduced locally. The existing `testSuccessfulSpillPropagatesSourceCloseFailure` checks exception propagation but does not check that the spill directory is empty afterward. ### Environment - Hudi version: `1.3.0-SNAPSHOT`, reproduced at `29cdee910a0`. - Component: shared LSM file-group reader in `hudi-common`; reproduced directly at the iterator level. - Configuration: writable local spill directory and an input selected for spilling. No engine-specific configuration is required for the iterator-level reproduction. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
