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

   ### Describe the issue this Pull Request addresses
   
   `TestMultipleHoodieJavaWriteClient.testOccWithMultipleWriters` is flaky. It 
runs three concurrent Java write clients under `OPTIMISTIC_CONCURRENCY_CONTROL` 
and deliberately creates contention (20 records over keys repeated twice). When 
two concurrent commits touch overlapping file groups, OCC correctly aborts one 
of them by throwing `HoodieWriteConflictException` (from 
`SimpleConcurrentFileWritesConflictResolutionStrategy`). The test never handles 
that exception, so it propagates out of the parallel commit loop and fails the 
test whenever the race lands. The conflict is correct behavior, not a bug, so 
the flakiness lives in the test itself.
   
   ### Summary and Changelog
   
   This test was added under HUDI-5583 to validate that concurrent Java writers 
do not deadlock, not that every commit succeeds. This change makes it tolerate 
the conflict OCC is designed to throw:
   
   - Catch `HoodieWriteConflictException` around `writer.commit(...)`. An 
aborted commit is an acceptable outcome under OCC contention, so it is logged 
and skipped rather than failing the test.
   - Move the writer return into a `finally` block so the writer pool is never 
starved when a commit is aborted (previously a thrown commit also leaked the 
writer).
   
   The conflict-resolution path already releases the transaction lock in a 
`finally` block, so the writer is safe to reuse after an aborted commit.
   
   ### Impact
   
   Test-only change. No production code or public API is affected.
   
   ### Risk Level
   
   low
   
   Verified locally on the Java client. Forcing maximum contention (collapsing 
all records onto a single file group) reproduces the failure on every run with 
the exact `HoodieWriteConflictException` (wrapping 
`ConcurrentModificationException`, "overlapping file groups") observed in CI. 
With this change the same workload completes: conflicts are caught and 
tolerated. The unmodified test (both COPY_ON_WRITE and MERGE_ON_READ) passes 
with no checkstyle violations.
   
   ### 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