cshuo opened a new issue, #20117: URL: https://github.com/apache/hudi/issues/20117
### Bug Description **What happened:** `HoodieNativeLogFormatWriter.closeFileWriters()` closes the data and delete writers sequentially. If `dataFileWriter.close()` throws, or the subsequent `getFileFormatMetadata()` call throws an exception other than the explicitly handled `UnsupportedOperationException`, execution exits before closing the delete writer and clearing writer references and record positions. This affects both `close()` and `flushAppend()`. The delete writer can remain open, and stale state can survive the failed cleanup. A failure in `deleteFileWriter.close()` also skips the remaining state cleanup. **What was expected:** - Attempt to close both writers even if one close operation or data-file metadata retrieval fails. - Clear each writer reference and its buffered record positions after attempting to close that writer, including failure paths. - Preserve the first exception and attach subsequent close failures as suppressed exceptions. - Repeated close calls should not retry writers whose close has already been attempted. **Steps to reproduce:** 1. Create a native log writer and append both a data record and a delete record so that both underlying writers exist. 2. Inject an `IOException` from the data writer's `close()`. Alternatively, enable column stats and inject an `IllegalStateException` from `getFileFormatMetadata()` after data close succeeds. 3. Call `close()` or `flushAppend()`. 4. Observe that the delete writer's `close()` is not invoked and pending writer state remains. ### Environment **Hudi version:** 1.3.0-SNAPSHOT; observed in the local checkout before the fix, at commit `ead194cce54`. **Component:** `hudi-client/hudi-client-common`, `org.apache.hudi.io.cdc.HoodieNativeLogFormatWriter`. **Query engine:** Engine-independent writer lifecycle issue; reproducible with mocked file writers. **Relevant configuration:** Native MOR log files with both data and delete writes. Column stats indexing is required only for the metadata-retrieval failure variant. ### Suggested Fix Separate each writer's close and state cleanup, use `finally` to clear state after a close attempt, and reuse `CloseableUtils.closeSuppressing()` to retain the original failure while still closing the other writer. -- 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]
