danny0405 opened a new pull request, #20452: URL: https://github.com/apache/hudi/pull/20452
### Describe the issue this Pull Request addresses Closes #20370. When a Hudi Structured Streaming micro-batch exhausts its write attempts, `HoodieStreamingSink` calls `System.exit(1)`. A single failed query therefore terminates the shared driver, including unrelated queries and Spark Connect sessions. ### Summary and Changelog - Throw a `HoodieException` containing the batch ID and the last write failure, allowing Spark to report a `StreamingQueryException`. - Retain the existing graceful sink cleanup performed by `retry`; remove the subsequent redundant forced reset and JVM exit. - Add regression coverage with one and three write attempts: preserve the failure cause, leave the failed batch uncommitted, keep an unrelated query processing, and replay the failed batch after restarting from the same checkpoint. - Document query failure and caller-managed restart in the streaming retry configuration description. No code was copied. ### Impact Exhausted writes fail the affected streaming query while leaving the driver JVM running. Applications that relied on process exit must handle query termination or use `awaitTermination` and let their orchestrator decide how to restart. Retry settings and `hoodie.datasource.write.streaming.ignore.failed.batch` retain their existing behavior. No public API, storage-format, or successful-write performance changes. ### Risk Level Low. The runtime change is confined to the terminal failure branch after retries and cleanup. Regression coverage exercises failure isolation and checkpoint recovery; existing tests cover ignored failures and async-service cleanup. ### Documentation Update Updated `STREAMING_RETRY_CNT` configuration documentation to explain that exhaustion fails the query and the caller controls restarting it. No configuration keys or defaults were added or changed. ### Testing Passed on Java 17 with Spark 3.5 / Scala 2.12 and Spark 4.1.1 / Scala 2.13: **4 tests, 0 failures, 0 errors, 0 skipped on each profile**. - `testExhaustedRetriesFailOnlyTheHudiQuery` with one and three attempts. - `testStructuredStreamingIgnoreFailedBatch`. - `testSinkResetWithAsyncServiceRunningDoesNotHang`. Built the full dependency reactor with `-pl hudi-spark-datasource/hudi-spark -am -Punit-tests`, selecting the methods above with `-Dtest=TestStructuredStreaming#testExhaustedRetriesFailOnlyTheHudiQuery+testStructuredStreamingIgnoreFailedBatch+testSinkResetWithAsyncServiceRunningDoesNotHang`, plus `-DfailIfNoTests=false -Dsurefire.failIfNoSpecifiedTests=false -DwildcardSuites=none`. Ran `test -Dspark3.5` and a clean `clean test -Dspark4.1 -Dscala-2.13` build. Maven style/license checks passed. Also passed `git diff --check`, PR title validation against the workflow's pattern and allowed types, and `scripts/pr_compliance.py`. These are local Structured Streaming tests; a separate Spark Connect server/client test was not run. ### 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]
