This is an automated email from the ASF dual-hosted git repository. voonhous pushed a commit to branch release-1.2.1 in repository https://gitbox.apache.org/repos/asf/hudi.git
commit 2d84d0ca5540a90009ef8f9607b9c0fd02a0ce74 Author: Y Ethan Guo <[email protected]> AuthorDate: Fri Jul 3 07:57:48 2026 -0700 test: handle expected OCC conflict in concurrent Java writer test (#19124) testOccWithMultipleWriters runs concurrent Java write clients under optimistic concurrency control and intentionally contends on the same file groups. OCC aborts one of two conflicting commits by throwing HoodieWriteConflictException, which the test did not handle, so it failed intermittently. Catch the expected conflict and always return the writer to the pool so the test validates deadlock freedom without flaking. (cherry picked from commit 562c3d94ba235144b0777554184b490352c9bc5f) --- .../common/TestMultipleHoodieJavaWriteClient.java | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/hudi-client/hudi-java-client/src/test/java/org/apache/hudi/client/common/TestMultipleHoodieJavaWriteClient.java b/hudi-client/hudi-java-client/src/test/java/org/apache/hudi/client/common/TestMultipleHoodieJavaWriteClient.java index f9d95afa8d9f..50e8d5683283 100644 --- a/hudi-client/hudi-java-client/src/test/java/org/apache/hudi/client/common/TestMultipleHoodieJavaWriteClient.java +++ b/hudi-client/hudi-java-client/src/test/java/org/apache/hudi/client/common/TestMultipleHoodieJavaWriteClient.java @@ -35,6 +35,7 @@ import org.apache.hudi.config.HoodieCleanConfig; import org.apache.hudi.config.HoodieIndexConfig; import org.apache.hudi.config.HoodieLockConfig; import org.apache.hudi.config.HoodieWriteConfig; +import org.apache.hudi.exception.HoodieWriteConflictException; import org.apache.hudi.index.HoodieIndex; import org.apache.hudi.keygen.constant.KeyGeneratorType; import org.apache.hudi.storage.StorageConfiguration; @@ -207,13 +208,24 @@ public class TestMultipleHoodieJavaWriteClient { String startCommitTime = writer.startCommit(); List<WriteStatus> s = writer.upsert(Collections.singletonList(record), startCommitTime); - writer.commit(startCommitTime, s); - LOGGER.info("Completed commit"); - synchronized (writerQueue) { - try { - writerQueue.put(writer); - } catch (InterruptedException e) { - throw new RuntimeException(e); + try { + writer.commit(startCommitTime, s); + LOGGER.info("Completed commit"); + } catch (HoodieWriteConflictException e) { + // Under OPTIMISTIC_CONCURRENCY_CONTROL, two writers updating overlapping file + // groups conflict and one of them is aborted by design. This test validates that + // concurrent writers do not deadlock, so an aborted commit is an expected outcome + // and must not fail the test. + LOGGER.info("Commit {} was aborted by an expected OCC conflict", startCommitTime); + } finally { + // Always return the writer to the pool, even when its commit was aborted, so the + // remaining records are not starved of writers. + synchronized (writerQueue) { + try { + writerQueue.put(writer); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } } } }
