cshuo opened a new pull request, #20030:
URL: https://github.com/apache/hudi/pull/20030
### Describe the issue this Pull Request addresses
Closes #20025.
If opening or initializing a later LSM sorted run fails,
`LsmFileGroupRecordIterator` construction aborts without closing readers opened
earlier. Their I/O resources and spill files remain unreleased because the
caller cannot close an iterator whose construction failed. A reader whose first
`advance()` fails is also leaked because it has not yet been registered.
### Summary and Changelog
- Close all registered readers when `initializeReaders()` throws, preserving
the original throwable and attaching cleanup failures as suppressed exceptions
while continuing cleanup.
- Register each reader before its first `advance()` so initialization
cleanup also closes the reader whose first read fails. Remove and close empty
readers immediately.
- Add six regression cases covering later log-open failures, first-read
failures with direct and spilled logs, spill-file removal, and continued
cleanup after a reader fails to close.
Validation: `TestLsmFileGroupRecordIterator`,
`TestSpillableLsmRecordIterator`, and `TestCloseableUtils` passed with 32
tests, zero failures, and zero errors. Checkstyle, license checks, and `git
diff --check` passed.
```sh
mvn -pl hudi-common -am \
-Dtest=TestLsmFileGroupRecordIterator,TestSpillableLsmRecordIterator,TestCloseableUtils
\
-Dsurefire.failIfNoSpecifiedTests=false \
-DskipITs -DskipSparkTests -DskipScalaTests test
```
Tests used the Mockito 5.21.0 JAR as a Java agent through
`JAVA_TOOL_OPTIONS` for the local test environment.
### Impact
Releases readers and their spill files when LSM reader initialization fails.
No public API or configuration changes; successful merge behavior is unchanged.
### Risk Level
Low. The change affects initialization ownership and failure cleanup;
regression tests verify successful merging as well as cleanup and exception
preservation.
### Documentation Update
None.
### Contributor's checklist
- [ ] Read through [contributor's
guide](https://hudi.apache.org/contribute/how-to-contribute)
- [x] Enough context is provided in the sections above
- [x] Adequate tests were added if applicable
--
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]