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

   ### Describe the issue this Pull Request addresses
   
   Closes #18331.
   
   Azure CI flakes repeatedly on `test-spark-java17-java-tests-part2` with
   
   ```
   Caused by: java.net.BindException: Address already in use
   Caused by: org.apache.hudi.exception.HoodieLockException: Failed to connect 
to ZooKeeper within 10000 ms
     at 
org.apache.hudi.client.transaction.lock.BaseZookeeperBasedLockProvider.<init>(BaseZookeeperBasedLockProvider.java:86)
   ```
   
   These have surfaced on unrelated PRs (#18147, #18650) that don't touch lock 
providers, ZK, or the test harness — pointing at a port-bind / leaked-server 
flake originating in the test infrastructure itself.
   
   ### Summary and Changelog
   
   
`TestHoodieClientMultiWriter.testHoodieClientBasicMultiWriterWithEarlyConflictDetection`
 creates a Curator `TestingServer` mid-method and only closes it at the tail of 
the test body, after ~70 lines of write-client work and several `assertThrows` 
/ `assertDoesNotThrow` calls. Any failed assertion or unexpected exception 
short of the tail leaks the `TestingServer` — its bound ephemeral port, its 
temp ZK data dir, and a handful of background threads.
   
   surefire is configured with `forkCount=1` and `reuseForks=true` for the 
`hudi-spark` module, so a single leaked `TestingServer` persists across every 
later test in the same JVM. We've seen this manifest as a late-suite 
`BindException` + `Failed to connect to ZooKeeper within 10000 ms` failure, 
repeatedly on the same parameter combination across reruns.
   
   Changes:
   
   - Add a `currentTestingServer` instance field; the test method records the 
active server there.
   - Strengthen `@AfterEach` to always close `currentTestingServer` before 
delegating to `cleanupResources()`. This is the belt-and-suspenders path that 
catches leaks from any present or future test method in this class.
   - Wrap the body of 
`testHoodieClientBasicMultiWriterWithEarlyConflictDetection` in `try/finally` 
so the server (and the four write clients) are closed on every exit path, 
including failed assertions.
   - Add a small `closeQuietly(SparkRDDWriteClient)` helper so the `finally` 
block does not mask the original failure with a secondary `close()` exception.
   
   ### Impact
   
   Test-only change. No production code or public API is touched.
   
   ### Risk Level
   
   none — only test code.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [x] 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