danny0405 opened a new pull request, #20156:
URL: https://github.com/apache/hudi/pull/20156
### Describe the issue this Pull Request addresses
Flink Sink V1 already delegates cleaning and compaction commits to
table-service handlers, while Sink V2 maintains separate implementations. This
duplication lets buffering, rollback, checkpoint cleaning, and
data/metadata-table composition diverge between the two APIs.
The compaction handler factory also leaves its newly created data-table
client without an owner when only metadata compaction is enabled. Both clients
need cleanup if handler construction fails.
### Summary and Changelog
- Delegate Sink V2 compaction commits and checkpoint-driven cleaning to the
existing `TableServiceHandlerFactory`, matching Sink V1 and reusing
data/metadata-table composition.
- Move abnormal compaction-event logging into the shared handler so both
sink adapters delegate event processing directly.
- Create cleaning clients only when asynchronous cleaning is enabled and
keep them local to initialization. Clustering sinks own and close their
separate commit clients, including when cleaner shutdown fails.
- Retain the data-table client in the metadata-only compaction handler for
cleanup, and close created clients on factory initialization failures while
preserving suppressed exceptions.
- Add or update tests for checkpoint cleaning, metadata compaction/log
compaction routing, successful commits, rollback, and client ownership and
cleanup failures. Update the compaction failover test helper to create its own
inspection client.
Existing Hudi handler code is reused; no external code was copied.
### Impact
Affects the Flink cleaning, compaction-commit, and clustering-commit
lifecycle. Sink V2 now uses the same metadata-table-aware handlers as Sink V1.
Asynchronous clustering uses separate cleaning and commit clients with explicit
cleanup.
No SQL/DataStream entry-point, configuration/default, or storage-format
changes. Internal sink inheritance changes: cleaning functions no longer expose
a protected write client, and Sink V2 cleaning state moves into the handler. No
performance benchmark was run.
### Risk Level
medium
Changes affect checkpoint cleaning and table-service commit/cleanup paths.
Focused validation passed: **50 tests, 0 failures, 0 errors, 0 skipped**,
covering the factory, composite handlers, default cleaner, Sink V2 cleaning and
compaction, and both clustering adapters.
```bash
mvn -o -pl hudi-flink-datasource/hudi-flink -am \
-Dtest=TestTableServiceHandlerFactory,TestCleanFunctionV2,TestCompactionCommitSinkV2,TestClusteringCommitSinkV2,TestDefaultCleanHandler,TestCompositeHandlers,TestClusteringCommitSink
\
-Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false test
```
`git diff --check` also passed. The full test suite and end-to-end Flink
jobs were not run.
### Documentation Update
none — this consolidates existing table-service behavior and resource
management without introducing a new user-facing feature, configuration, or
default.
### 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]