fhan688 opened a new pull request, #18909:
URL: https://github.com/apache/hudi/pull/18909

   ### Describe the issue this Pull Request addresses
   
     `HoodieLogFormatWriter#appendBlocks` can leave the underlying 
`FSDataOutputStream` open when an exception is thrown after the output stream 
has already been opened, for example while writing log block bytes. In this
     failure path, the writer does not release the stream/lease until a later 
close path, which may not be reached by callers.
   
     This PR ensures the output stream is closed on append failure while 
preserving the original failure as the primary exception.
   
   ### Summary and Changelog
   
     This PR improves failure-path resource cleanup in `HoodieLogFormatWriter`.
   
     Changes:
     - Close the underlying output stream when `appendBlocks` fails after 
opening the stream.
     - Preserve the original append exception type and message instead of 
wrapping it.
     - Add close failures as suppressed exceptions so they do not hide the 
append failure.
     - Ensure `closeStream` still closes the output stream even when `sync()` 
fails.
     - Add unit tests covering:
       - append write failure closes the output stream;
       - append write failure is preserved when close also fails;
       - close still closes the output stream when `sync()` fails.
   
     No code was copied.
   
   ### Impact
   
     No public API change.
   
     Successful append behavior is unchanged. This PR does not restore 
append-time `sync()`/`hsync`, so the existing append performance behavior 
remains intact.
   
     The behavioral change is limited to failure handling:
     - failed appends now release the writer output stream immediately;
     - close failures are attached as suppressed exceptions instead of 
replacing the original append failure.
   
   ### Risk Level
   
     low
   
     The change is scoped to error handling and resource cleanup in 
`HoodieLogFormatWriter`. The successful write path remains functionally 
unchanged.
   
     Verification:
     ```bash
     mvn -pl hudi-hadoop-common -am -DskipITs -Dcheckstyle.skip=true 
-DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false 
-Dtest=TestHoodieLogFormatWriter test
   
     Result:
     Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
   ```
   ### Documentation Update
   
     none
   
     No new config, public API, or user-facing feature is added.
   
   ### 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]

Reply via email to