Repository navigation
[Fix][Connector-V2] Route Paimon fixed buckets through multi-table sinks - #12366
201811510411lw wants to merge 13 commits into
Conversation
Route fixed-bucket Paimon records through the actual MultiTableSink wrapper, preserve schema-control destinations without data conversion, and cover the production factory/processor wiring with MiniCluster and Paimon regressions. Retain the original PaimonFixedBucketPartitioner and sink data partitioning SPI from PR apache#12301. Keep global-commit recovery and checkpoint-state changes outside this routing fix. Co-authored-by: zhangshenghang <zhangshenghang@users.noreply.github.com>
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
Paimon "fixed bucket" tables require that every row belonging to the same physical bucket always lands on the same parallel sink writer; otherwise two writers can race to update the same bucket and corrupt it. PaimonSink already exposed a SupportSinkDataPartition style capability for this, but in the real Flink execution path almost every Paimon sink is wrapped by MultiTableSink (even single-table jobs), and the old wiring only checked the per-table sink's capability, never the actual wrapper that reaches the runtime. As a result the routing never activated on the real user path, and parallel writers could silently write conflicting changes to the same bucket. This PR makes MultiTableSink itself resolve and expose the routing capability, wires a new SinkWriteRoutingPartitioner into the Flink sink pipeline to apply it, and makes sure schema-control rows (zero-field broadcast rows) still reach every writer once instead of being converted as data.
Before/After example
Before: a streaming CDC job with sink.parallelism = 2 writing into a Paimon table with bucket = 4 (fixed bucket mode) is silently wrapped in MultiTableSink. No routing is applied, so row A (bucket 2) and its later update can land on different writer subtasks, producing lost or duplicated bucket writes.
After: the same job now resolves a SinkDataPartitioner from the wrapper, and Flink's SinkWriteRoutingPartitioner.prepare() inserts a partitionCustom before the sink so every row for bucket 2 (and every row sharing a primary key) always goes to the same writer subtask, regardless of source parallelism. If the user instead configures multi_table_sink_replica > 1 with a fixed-bucket table, or two independent source tables targeting the same physical Paimon table, the job now fails fast at initialization with a clear error instead of silently corrupting data.
1. Code Change Review
1.1 Core Logic Analysis
Runtime flow reached by this change (normal streaming path, not a recovery/boundary path):
Source (CDC/Fake) -> [optional schema-evolution operator] -> SinkExecuteProcessor.execute()
-> FactoryUtil.createAndPrepareSink() + handleSaveMode() (sets/refreshes PaimonSink.paimonTable via SupportLoadTable)
-> tryGenerateMultiTableSink() -> MultiTableSink wraps per-table PaimonSink instances
-> createVersionSpecificDataStreamSink()
-> SinkWriteRoutingPartitioner.prepare(ds, sink, parallelism, isStreaming)
-> SupportSinkDataPartition.resolve(sink, parallelism) // NEW: now resolves MultiTableSink's own capability
-> if routing present: partitionCustom(RoutingKeySelector) // NEW shuffle
-> if schema evolution enabled: BroadcastSchemaHandler transform (unchanged when routing absent)
-> ds.sinkTo(FlinkSink(sink))
Key findings, traced against the actual (unmodified) source, not just the diff:
MultiTableSink.getSinkDataPartitioner()(seatunnel-api/.../multitablesink/MultiTableSink.java:238) correctly resolves each active table's ownSupportSinkDataPartitionvia the existing per-table sinks map, rejects mixed routed/unrouted sinks, rejectsmulti_table_sink_replica != 1when routing is active, and rejects two source tables sharing the same physicaltargetIdentifier(). This is exactly the missing wrapper-level check the PR claims to add, and I verified it against the realMultiTableSinkused bySinkExecuteProcessor, not a mock.- I specifically checked whether
PaimonSink.paimonTable(used byPaimonSink.getSinkDataPartitioner()to readbucketMode()) could still benullat routing-resolution time for a first-run "auto create table" job (schema save modeCREATE_SCHEMA_WHEN_NOT_EXIST), which would silently disable routing exactly in the scenario this PR targets. It does not:AbstractSinkExecuteProcessor.execute()callshandleSaveMode(sink)(which invokesPaimonSaveModeHandler.handleSchemaSaveMode()->supportLoadTable.setLoadTable(paimonTable)) beforetryGenerateMultiTableSink()and beforecreateVersionSpecificDataStreamSink(), sopaimonTableis always populated by the time routing is resolved. This is a real, non-obvious correctness dependency and it is correctly ordered. SinkWriteRoutingPartitioner(new file,seatunnel-core/.../SinkWriteRoutingPartitioner.java) composes correctly with the pre-existingBroadcastSchemaSinkOperator/LocalSchemaCoordinatorschema-evolution machinery: when routing is active and schema evolution is enabled, it first expands eachschema_change_broadcastrow intoparallelismcontrol rows (oneschema_subtask_idper writer) at the upstream parallelism via.forward()(no shuffle before routing), then explicitly key-routes each control row to its target writer viapartitionCustom.BroadcastSchemaSinkOperator.handleBroadcastedSchemaChange()still dedupes by(tableId, epoch), so even if the upstream schema-evolution operator emits more than one broadcast row for the same DDL (its own parallel instances), duplicates are safely absorbed downstream. This guarantees delivery to every writer even though, as far as I can tell from the code, the pre-existing non-routed path never used a genuine Flink.broadcast()partition and instead relied on default rebalance — a pre-existing characteristic this PR does not change for the non-routed path, so it is out of scope here, but worth knowing.- When routing is not present (
SupportSinkDataPartition.resolve()returns empty, i.e. every other sink and non-HASH_FIXEDPaimon tables),SinkWriteRoutingPartitioner.prepare()reduces to exactly the oldBroadcastSchemaHandlertransform with no other change — I diffed this line by line across all three Flink starters (1.13, 1.15/common, 2.0) and confirmed byte-for-byte equivalent behavior for the untouched path.
1.2 Compatibility Impact
Partially incompatible, and correctly documented. Fixed-bucket Paimon sinks now activate routing automatically; configurations that previously ran (incorrectly, with silent bucket corruption risk) — multi_table_sink_replica > 1 on a fixed-bucket sink, or two independent source-table writers targeting one physical Paimon table — now fail fast at job initialization. This is called out in docs/en(/zh)/introduction/concepts/incompatible-changes.md and docs/en(/zh)/connectors/sink/Paimon.md with correct migration guidance (set multi_table_sink_replica = 1, separate sink definitions, merge streams before one sink). All other sinks and non-fixed-bucket Paimon tables are unaffected. Checkpoint/savepoint serialization is untouched (all new operators are stateless).
1.3 Performance/Side-Effect Analysis
See Issue 1 below for a concrete, evidence-backed finding: routing computes a full Paimon BinaryRow conversion per record purely to pick a bucket, and the same row is converted again in the real write path, doubling conversion cost for every record on fixed-bucket tables. The partitionCustom shuffle itself is an expected, documented cost (network shuffle when writer parallelism > 1), not a regression.
1.4 Error Handling and Logging
Failures are surfaced as clear, typed exceptions at initialization (UnsupportedOperationException for mixed routing/replica misconfiguration, IllegalArgumentException for duplicate physical targets) with actionable messages naming the offending tables. At runtime, SinkWriteRoutingPartitioner.partition() and RoutingKeySelector.getKey() validate the writer index / schema_subtask_id range and throw IllegalStateException/IllegalArgumentException rather than silently misrouting — good defensive behavior for a bucket-correctness-critical path. See Issues 1-2 for the two things I'd still like tightened.
2. Code Quality Assessment
2.1 Coding Standards
New public types (SinkDataPartitioner, SupportSinkDataPartition, PaimonFixedBucketPartitioner, SinkWriteRoutingPartitioner) all carry class/method Javadoc explaining contract and constraints (e.g. select() range, targetIdentifier() semantics). ASF license headers present on all new files. No wildcard imports, no System.out.println, no inline single-line Javadoc violations spotted.
2.2 Test Coverage and Test Stability
Coverage is thorough and exercises the real path, not just mocks: MultiTableWriteRoutingTest and SupportSinkDataPartitionTest cover the API contract; PaimonFixedBucketPartitionerTest covers same-key-same-writer for INSERT/UPDATE/DELETE; SinkWriteRoutingPartitionerTest covers the expander/selector/partitioner units directly; PaimonFlinkBucketRoutingTest runs a real Flink MiniCluster against the actual SinkExecuteProcessor/factory path with multiple tables, buckets, source/sink parallelism combinations, and checkpoint-boundary changes; a new PaimonIT container test extends E2E coverage (Flink-only, correctly disabled for Spark/Zeta via EngineType.SPARK, EngineType.SEATUNNEL, since this is a Flink-specific wiring fix).
Mandatory flaky-test rating: Risk present. PaimonFlinkBucketRoutingTest.submit() (.../PaimonFlinkBucketRoutingTest.java around line 1168) uses environment.enableCheckpointing(200) (200ms checkpoint interval) combined with a @Timeout(120) across a 6-case parameterized matrix, each spinning up its own local Flink MiniCluster. The polling itself (awaitRows()) is a proper bounded poll against System.nanoTime() deadlines rather than a bare Thread.sleep, which is the right pattern, but the tight 200ms checkpoint interval combined with MiniCluster startup overhead under a loaded shared CI runner is a plausible source of intermittent timeouts. Not high risk (no unbounded waits, no order dependence, resources are closed via AutoCloseable Fixture/cancelIfRunning), but worth watching if this test flakes on CI.
2.3 Documentation Updates
EN and ZH docs are updated together and consistent (Paimon.md, sink-connector-development.md, incompatible-changes.md), and match the actual enforced constraints (multi_table_sink_replica = 1, no mixed bucket modes, no duplicate physical targets) rather than just describing intent.
3. Architectural Soundness
3.1 Fix type: This is a precise, root-cause fix, not a workaround. It moves the capability check to the actual object that reaches the runtime (MultiTableSink) instead of special-casing Paimon in the engine, and it builds on top of the existing SupportSinkDataPartition SPI rather than inventing a parallel mechanism.
3.2 Maintainability: The new SinkWriteRoutingPartitioner is cleanly isolated in its own file and shared by all three Flink starters instead of being duplicated inline, which is a maintainability improvement over the previous copy-pasted BroadcastSchemaHandler blocks.
3.3 Extensibility: SupportSinkDataPartition/SinkDataPartitioner is a generic SPI; other connectors with similar "same key must land on the same writer" requirements can adopt it without further engine changes.
3.4 Historical-version compatibility: Verified line-by-line that the non-routed path (everything except HASH_FIXED Paimon tables) is functionally unchanged across all three Flink starters. No checkpoint format changes, no SPI removals, no default value changes for unrelated sinks.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | Full row is converted twice per record for fixed-bucket routing (once to pick the bucket, once to write) | connector-paimon/.../PaimonFixedBucketPartitioner.java select(); connector-paimon/.../PaimonSinkWriter.java write() (~line 233) |
Medium |
| 2 | MultiTableWriteRouting.select() throws for any row whose table isn't in the routes map at DAG-construction time, on the per-record hot path |
seatunnel-api/.../multitablesink/MultiTableSink.java (MultiTableWriteRouting.select) |
Low |
| 3 | Container E2E test only exercises bucket = 1, so it doesn't verify records actually split across different writers by bucket at the container level (MiniCluster unit tests do cover this) |
connector-paimon-e2e/.../fake_cdc_to_paimon_fixed_bucket_routing.conf |
Low |
5. Merge Recommendation
Conclusion: Ready to merge
- Blockers — must be fixed: None found. The core routing logic is correct, composes safely with the existing schema-evolution broadcast machinery, is backward compatible for every unaffected sink, and is well tested against the real Flink execution path.
- Recommended fixes — non-blocking:
- Issue 1: avoid the second full-row conversion in the routing hot path (e.g. extract only the fields needed to compute the bucket, or let the writer reuse the already-converted row) — worth doing given this is meant to run at very high per-record throughput.
- Issue 2: consider whether an unknown-table row during routing should fail the job or be handled the same way
skippedTablesalready is, for consistency. - Issue 3: add a
bucket > 1case to the container E2E test if practical, to mirror the MiniCluster coverage.
Overall this is a solid, well-scoped fix that closes a real correctness gap (#12243) at the layer that actually matters (the MultiTableSink wrapper), with good regression coverage and honest documentation of its limits (no online DDL, no new recovery/rescaling guarantees). CI on the PR's own head commit was still queued at review time (not failing) — please confirm it goes green before merge. I don't see a better alternative approach; hooking into the existing SupportSinkDataPartition SPI at the wrapper level is the right place for this fix.
|
I investigated the failing
These are focused local results, not a full CI pass for #12366. I will sync this PR with |
|
Thanks for the detailed CI investigation. I independently pulled the I've gone ahead and completed a full re-review of the current head ( |
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
Paimon "fixed bucket" tables require that every row belonging to the same physical bucket always lands on the same parallel sink writer; otherwise two writers can race to update the same bucket and corrupt it. PaimonSink already exposed a SupportSinkDataPartition-style capability for this, but in the real Flink execution path almost every Paimon sink is wrapped by MultiTableSink (even single-table jobs), and the old wiring only checked the per-table sink's capability, never the actual wrapper object that reaches the runtime. As a result the routing never activated on the real user path, and parallel writers could silently write conflicting changes to the same bucket. This PR makes MultiTableSink itself resolve and expose the routing capability, wires a new SinkWriteRoutingPartitioner into the Flink sink pipeline to apply it, and makes sure schema-control rows (zero-field broadcast rows) still reach every writer once instead of being converted as data.
One-line re-review note: I re-reviewed the current head (e4418d06) against the merge base of dev from scratch, per the standard checklist. The only difference from my previous round's head (5de24b8c) is a [Chore][Core] Merge latest Apache dev commit that pulls in unrelated upstream changes (JDBC, MQTT, OpenMLDB, Prometheus, RocketMQ E2E, two new incompatible-changes.md entries from other PRs, etc.) — I diffed every file this PR itself touches between the two commits and confirmed byte-for-byte identical content except for the shared incompatible-changes.md/incompatible-changes.md (zh) files gaining unrelated entries above/below this PR's own entry. So all findings below are a fresh, independent re-verification of the same code, not a rubber stamp of my earlier notes — and I did not find anything my last round missed, so no apology is owed this time; I'm restating the findings against the current head for the record and to close out the re-review request.
Before/After example
Before: a streaming CDC job with sink.parallelism = 2 writing into a Paimon table with bucket = 4 (fixed bucket mode) is silently wrapped in MultiTableSink. No routing is applied, so row A (bucket 2) and its later update can land on different writer subtasks, producing lost or duplicated bucket writes.
After: the same job now resolves a SinkDataPartitioner from the wrapper, and Flink's SinkWriteRoutingPartitioner.prepare() inserts a partitionCustom before the sink so every row for bucket 2 (and every row sharing a primary key) always goes to the same writer subtask, regardless of source parallelism. If the user instead configures multi_table_sink_replica > 1 with a fixed-bucket table, or two independent source tables targeting the same physical Paimon table, the job now fails fast at initialization with a clear error instead of silently corrupting data.
1. Code Change Review
1.1 Core Logic Analysis
Runtime flow reached by this change (normal streaming/batch path, not a recovery/boundary path) — verified line-by-line against the current head, not just described:
Source (CDC/Fake) -> [optional SchemaOperator, source-side] -> AbstractSinkExecuteProcessor.execute()
-> handleSaveMode(sink) [AbstractSinkExecuteProcessor.java:170] (sets/refreshes PaimonSink.paimonTable via SupportLoadTable)
-> tryGenerateMultiTableSink(...) [AbstractSinkExecuteProcessor.java:192] (MultiTableSink wraps per-table PaimonSink instances)
-> createVersionSpecificDataStreamSink(...) [AbstractSinkExecuteProcessor.java:212]
-> SinkWriteRoutingPartitioner.prepare(ds, sink, parallelism, isStreaming)
-> SupportSinkDataPartition.resolve(sink, parallelism) // NEW: now resolves MultiTableSink's own capability
-> if routing present: partitionCustom(RoutingKeySelector) // NEW shuffle
-> if schema evolution enabled: BroadcastSchemaHandler transform (unchanged when routing absent)
-> ds.sinkTo(FlinkSink(sink))
Key findings, re-traced against the current head's actual source:
MultiTableSink.getSinkDataPartitioner()(seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSink.java:121-152) resolves each active table's ownSupportSinkDataPartitionvia the real per-tablesinksmap (not a mock), rejects mixing routed and unrouted sinks in oneMultiTableSink, rejectsmulti_table_sink_replica != 1when routing is active, and rejects two source tables sharing the same physicaltargetIdentifier()(Paimon table location). This is exactly the missing wrapper-level check the PR claims to add.PaimonSink.getSinkDataPartitioner()(connector-paimon/.../PaimonSink.java,paimonTable == null || bucketMode() != HASH_FIXED -> Optional.empty()) depends onpaimonTablebeing populated before routing is resolved. I re-confirmed the call order inAbstractSinkExecuteProcessor.execute():handleSaveMode(sink)(line 170, which drivesPaimonSaveModeHandler->supportLoadTable.setLoadTable(paimonTable)) runs beforetryGenerateMultiTableSink()(line 192) and beforecreateVersionSpecificDataStreamSink()(line 212) where routing is resolved. SopaimonTableis always populated by the time routing is resolved, including for a first-run "auto create table" job. This is a real, non-obvious correctness dependency and it is correctly ordered in the current head.SinkWriteRoutingPartitioner(seatunnel-core/seatunnel-flink-starter/seatunnel-flink-starter-common/.../SinkWriteRoutingPartitioner.java) composes correctly with the pre-existing schema-evolution machinery. When routing is active and schema evolution is enabled, it first expands eachschema_change_broadcastrow intoparallelismcontrol rows (oneschema_subtask_idper writer) at the upstream parallelism via.forward()(no shuffle before routing), then explicitly key-routes each control row to its target writer viapartitionCustom. I traced theschema_change_eventvsschema_change_broadcastmarker lifecycle end to end (FlinkRowCollector.collect(SchemaChangeEvent)on the source side setsschema_change_event->SchemaOperator.processElement(), attached upstream of the sink pipeline inAbstractSourceExecuteProcessor, converts it toschema_change_broadcastviasendSchemaChangeEventToDownstream()-> only then does the row reachSinkWriteRoutingPartitioner.prepare()'s input). So theschema_change_eventbranch insideRoutingKeySelector.getKey()(line ~137) is unreachable on the real pipeline today; it is purely defensive/test-only code mirroring the same guard used elsewhere (FlinkSinkWriter). Not a bug, just worth knowing it's dead on the current topology.- When routing is not present (every other sink, and non-
HASH_FIXEDPaimon tables),SinkWriteRoutingPartitioner.prepare()reduces to exactly the old inlineBroadcastSchemaHandlertransform block with no other change. I diffed this against the pre-PRSinkExecuteProcessor.javain all three Flink starters (1.13, 2.0, starter-common) and confirmed the non-routed path is functionally unchanged.
1.2 Compatibility Impact
Partially incompatible, and correctly documented. Fixed-bucket Paimon sinks now activate routing automatically; configurations that previously ran (incorrectly, with silent bucket-corruption risk) — multi_table_sink_replica > 1 on a fixed-bucket sink, or two independent source-table writers targeting one physical Paimon table — now fail fast at job initialization. This is called out in docs/en(/zh)/introduction/concepts/incompatible-changes.md and docs/en(/zh)/connectors/sink/Paimon.md with correct migration guidance. All other sinks and non-fixed-bucket Paimon tables are unaffected. Checkpoint/savepoint serialization is untouched — all new operators (SinkWriteRoutingPartitioner, SchemaBroadcastExpander, RoutingKeySelector) are stateless, and MultiTableState/SinkIdentifier checkpoint-state keying is unchanged by this PR.
1.3 Performance/Side-Effect Analysis
See Issue 1 below (still present at the same location in the current head): routing computes a full Paimon BinaryRow/InternalRow conversion per record purely to pick a bucket (PaimonFixedBucketPartitioner.select() -> RowConverter.reconvert(...)), and PaimonSinkWriter.write() (line 233) converts the same row again in the real write path — doubling conversion cost for every record on fixed-bucket tables. The partitionCustom shuffle itself is an expected, documented cost (network shuffle when writer parallelism > 1), not a regression.
1.4 Error Handling and Logging
Failures are surfaced as clear, typed exceptions at initialization (UnsupportedOperationException for mixed routing/replica misconfiguration, IllegalArgumentException for duplicate physical targets) with actionable messages naming the offending tables. At runtime, SinkWriteRoutingPartitioner.partition() and RoutingKeySelector.getKey() validate the writer index / schema_subtask_id range and throw IllegalStateException/IllegalArgumentException rather than silently misrouting — good defensive behavior for a bucket-correctness-critical path. See Issue 2 for one hot-path exception concern I'd still like tightened.
2. Code Quality Assessment
2.1 Coding Standards
New public types (SinkDataPartitioner, SupportSinkDataPartition, PaimonFixedBucketPartitioner, SinkWriteRoutingPartitioner) all carry class/method Javadoc explaining contract and constraints. ASF license headers present on all new files. No wildcard imports, no System.out.println, no inline single-line Javadoc violations spotted.
- Issue 4 (Medium, new this round):
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SinkDataPartitioner.javauses the fully-qualifiedjava.util.Optionalinline in thetargetIdentifier()default method signature instead of adding animport java.util.Optional;(the sibling fileSupportSinkDataPartition.javain the same package does import it). Minor, but it's inconsistent with the rest of this same PR and with standard style — please just add the import.
2.2 Test Coverage and Test Stability
Coverage is thorough and exercises the real path, not just mocks: MultiTableWriteRoutingTest and SupportSinkDataPartitionTest cover the API contract; PaimonFixedBucketPartitionerTest covers same-key-same-writer for INSERT/UPDATE/DELETE; SinkWriteRoutingPartitionerTest covers the expander/selector/partitioner units directly, including the (currently unreachable-in-production) schema_change_event defensive branch; PaimonFlinkBucketRoutingTest runs a real Flink MiniCluster against the actual SinkExecuteProcessor/factory path with multiple tables, buckets, source/sink parallelism combinations, and checkpoint-boundary changes; a new PaimonIT container test extends E2E coverage (Flink-only, correctly disabled for Spark/Zeta via EngineType.SPARK, EngineType.SEATUNNEL, since this is a Flink-specific wiring fix).
Mandatory flaky-test rating: Risk present. PaimonFlinkBucketRoutingTest (seatunnel-connectors-v2/connector-paimon/src/test/java/org/apache/seatunnel/core/starter/flink/execution/PaimonFlinkBucketRoutingTest.java:313) uses environment.enableCheckpointing(200) (200ms checkpoint interval) across a @Timeout(120) parameterized matrix (lines 98/139/156), each spinning up its own local Flink MiniCluster. The polling itself (awaitRows(), line 373-375) is a proper bounded poll against System.nanoTime() deadlines rather than a bare Thread.sleep, which is the right pattern, but the tight 200ms checkpoint interval combined with MiniCluster startup overhead under a loaded shared CI runner is a plausible source of intermittent timeouts. Not high risk (no unbounded waits, no order dependence, resources are closed via AutoCloseable/cancelIfRunning), but worth watching if this test flakes on CI.
2.3 Documentation Updates
EN and ZH docs are updated together and consistent (Paimon.md "Flink fixed-bucket routing" section, sink-connector-development.md, incompatible-changes.md), and match the actual enforced constraints (multi_table_sink_replica = 1, no mixed bucket modes, no duplicate physical targets) rather than just describing intent. I re-diffed both incompatible-changes.md files against the merge commit and confirmed this PR's own entry is unchanged; the only delta in that file versus my last review is two unrelated entries (HTTP sink, JSON format) picked up from the dev merge.
3. Architectural Soundness
3.1 Fix type: This is a precise, root-cause fix, not a workaround. It moves the capability check to the actual object that reaches the runtime (MultiTableSink) instead of special-casing Paimon in the engine, and it builds on top of the existing SupportSinkDataPartition SPI rather than inventing a parallel mechanism.
3.2 Maintainability: SinkWriteRoutingPartitioner is cleanly isolated in its own file and shared by all three Flink starters instead of being duplicated inline, which is a maintainability improvement over the previous copy-pasted BroadcastSchemaHandler blocks.
3.3 Extensibility: SupportSinkDataPartition/SinkDataPartitioner is a generic SPI; other connectors with similar "same key must land on the same writer" requirements can adopt it without further engine changes.
3.4 Multi-table sink SPI checklist (per the coordinated-contract requirement for anything touching SupportMultiTableSinkWriter/MultiTableSink): PaimonSink already implements SupportMultiTableSink (pre-existing, PaimonSink.java:74, not new in this PR); PaimonSink.createWriter() returns PaimonSinkWriter, which implements SupportMultiTableSinkWriter<Void> (pre-existing, PaimonSinkWriter.java:83); PaimonSinkFactory.optionRule() already lists SinkConnectorCommonOptions.MULTI_TABLE_SINK_REPLICA in its .optional(...) set (pre-existing, PaimonSinkFactory.java:68). All three contract points check out — this PR correctly builds on the existing multi-table contract rather than bypassing it.
3.5 Historical-version compatibility: Verified line-by-line that the non-routed path (everything except HASH_FIXED Paimon tables) is functionally unchanged across all three Flink starters. No checkpoint format changes, no SPI removals, no default value changes for unrelated sinks.
4. Issue Summary
| Number | Issue | Location | Severity | Raised by another reviewer |
|---|---|---|---|---|
| 1 | Full row is converted twice per record for fixed-bucket routing (once to pick the bucket, once to write) | connector-paimon/.../bucket/PaimonFixedBucketPartitioner.java select(); connector-paimon/.../PaimonSinkWriter.java:233 |
Medium | No |
| 2 | MultiTableWriteRouting.select() throws for any row whose table isn't in the routes map, on the per-record hot path |
seatunnel-api/.../multitablesink/MultiTableSink.java (MultiTableWriteRouting.select) |
Low | No |
| 3 | Container E2E test only exercises bucket = 1, so it doesn't verify records actually split across different writers by bucket at the container level (MiniCluster unit tests do cover this) |
connector-paimon-e2e/.../fake_cdc_to_paimon_fixed_bucket_routing.conf |
Low | No |
| 4 | Fully-qualified java.util.Optional used instead of an import, inconsistent with the sibling file in the same PR |
seatunnel-api/.../sink/SinkDataPartitioner.java |
Low | No |
5. Merge Recommendation
Conclusion: Ready to merge
None of the four issues below are correctness blockers for the scenario this PR targets — the routing logic itself is correct, backward compatible for every unaffected sink, and well tested against the real Flink execution path (verified independently this round, not just carried over from my last review). I'm keeping the same overall conclusion as my last review:
- Blockers — must be fixed: None found in the core logic.
- Recommended fixes — non-blocking:
- Issue 1: avoid the second full-row conversion in the routing hot path (e.g. extract only the fields needed to compute the bucket, or let the writer reuse the already-converted row) — worth doing given this is meant to run at very high per-record throughput.
- Issue 2: consider whether an unknown-table row during routing should fail the job or be handled the same way
skippedTablesalready is, for consistency. - Issue 3: add a
bucket > 1case to the container E2E test if practical, to mirror the MiniCluster coverage. - Issue 4: add the missing
import java.util.Optional;inSinkDataPartitioner.java.
CI note: the current head's fork CI run has a single failing job, engine-v2-it (8, ubuntu-latest). I pulled the job log directly and it fails on exactly three tests: CheckpointCoordinatorFailoverIT.testStreamJobFailsAfterCheckpointTriggerDispatchFailure, SplitClusterFaultToleranceIT.testStreamJobCancelResolvesWhenWorkerCrashesBeforeCancelAck, and BackpressureSlowSinkIT.testCheckpointsKeepCompletingUnderSustainedBackpressure — none of which touch Paimon, MultiTableSink, or the Flink sink pipeline. These match known, separately tracked engine flakiness (worker-loss cancellation race, checkpoint-lock starvation), not this PR's diff, and the paimon-connector-it job itself is green on both JDK 8 and 11. I'd treat this as a CI/dev-sync item, not a source-level blocker, and would like to see it go green (via a dev sync once the referenced fixes land) before the final merge, but it does not change my Section 5 recommendation.
I don't see a better alternative approach; hooking into the existing SupportSinkDataPartition SPI at the wrapper level is the right place for this fix.
Sync dev through the merge of apache#12449 while preserving the existing Paimon routing patch.
|
@DanielLeens Thanks for the detailed review and suggestions. I agree that the performance optimization, unknown-table handling, and additional container E2E coverage are worth following up on. Given my current bandwidth, I would prefer to address these non-blocking improvements in follow-up PRs and keep this PR focused on the routing correctness fix. Regarding Issue 4, The branch has been synced with Apache Would you be comfortable proceeding with this PR and leaving the non-blocking improvements for follow-up work? |
|
@201811510411lw Thanks for the update and for syncing with I'm fine with keeping this PR scoped to the routing correctness fix. The remaining items from the review (skipping per-row work when routing isn't needed, defining behavior for rows whose table isn't in the wrapper, and a container-based E2E for the fixed-bucket + parallel writer scenario) are improvements on top of the fix rather than blockers, so follow-up PRs are acceptable. A few things before this goes in:
Once 1–3 are addressed I'll do a final pass and move to merge. |
|
@SEZ9 Thanks for the review. I completed the requested updates:
For the CI results, the first attempt on On the latest run, Could you please help trigger a fresh CI attempt once the queued rerun is cleared? I will confirm the final CI status after that run. |
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for the follow-up commit, for taking the Optional import and the follow-up checklist from @SEZ9's list, and for the detailed CI notes on the thread. I re-reviewed the latest head (682e9259e) from scratch against the merge base. The only commit since the head I approved (709750af9) is 682e9259e ("Tidy Paimon routing API and compatibility notes"): it adds import java.util.Optional; to SinkDataPartitioner.java and re-nests the "Flink Paimon fixed-bucket routing" section of both incompatible-changes.md files under "Engine Behavior Changes" (it used to sit directly under the empty "Dependency Upgrades" heading). I diffed every PR file against what I approved and nothing else changed. This round does surface two new points on the docs side (Issues 5 and 6 below). Issue 6 is something I should have caught in my last review, so sorry for missing it, that one is on me and not a regression from your new commit.
What Problem Does This PR Solve?
- User pain point: Paimon fixed-bucket tables need every row of one physical bucket to reach the same parallel sink writer. In the real Flink path almost every Paimon sink is wrapped in
MultiTableSink, and the old wiring only looked at the per-table sink, so routing never activated and parallel writers could race on the same bucket. - Fix approach:
MultiTableSinkresolves and exposes the routing capability itself, a newSinkWriteRoutingPartitionerapplies it in the Flink sink pipeline for all three Flink starters, and schema-control rows are routed to their target subtask without row conversion. - One-sentence summary: make fixed-bucket routing actually fire on the wrapped sink the runtime sees, and fail fast on configurations that cannot be routed safely.
1. Code Change Review
1.1 Core Logic Analysis
Runtime path, re-verified on this head:
Source -> [SchemaOperator, source side] -> AbstractSinkExecuteProcessor.execute()
-> handleSaveMode(sink) (PaimonSink.paimonTable is populated here)
-> tryGenerateMultiTableSink(...) (MultiTableSink wraps per-table PaimonSink)
-> SinkExecuteProcessor (flink-13: line 210, flink-20 / starter-common: line 53)
SinkWriteRoutingPartitioner.prepare(ds, sink, parallelism, isStreaming) SinkWriteRoutingPartitioner.java:48-81
SupportSinkDataPartition.resolve(sink, parallelism)
MultiTableSink.getSinkDataPartitioner(writerCount) MultiTableSink.java:123-160
per table: PaimonSink.getSinkDataPartitioner -> HASH_FIXED only PaimonSink.java:219
routing present -> [forward + SchemaBroadcastExpander] -> partitionCustom(RoutingKeySelector)
schema evolution -> BroadcastSchemaHandler (unchanged when routing is absent)
-> ds.sinkTo(FlinkSink(sink))
Key findings:
- The normal user path reaches this logic: every Flink job with a
HASH_FIXEDPaimon table passes throughMultiTableSink, so the wrapper-level check atMultiTableSink.java:123-160is exactly what the old code was missing. It rejects mixed routed/unrouted tables,multi_table_sink_replica != 1and two source tables targeting one physical location. - Ordering dependency still holds:
PaimonSink.getSinkDataPartitionerreturns empty whilepaimonTable == null, andhandleSaveModeruns before routing is resolved, so auto-created tables get routed on first run. - When routing is absent (every other sink, non-fixed-bucket Paimon)
prepare()reduces to the old inlineBroadcastSchemaHandlerblock, so the non-routed path is unchanged. - Precise root-cause fix, not a workaround.
RoutingKeySelector.getKeyvalidatesschema_subtask_idrange (line 142-147) andpartition()validates the writer index, so a bad index fails loudly instead of misrouting.
1.2 Compatibility Impact
Partially incompatible, and documented: configurations that used to run with a silent bucket-corruption risk now fail at initialization (multi_table_sink_replica > 1, mixed bucket modes, duplicate physical targets). No checkpoint or serialization format changes (the new operators are stateless). Other sinks are unaffected.
1.3 Performance / Side-Effect Analysis
See Issue 1: bucket selection reconverts every row (PaimonFixedBucketPartitioner.java:60-63) and the writer converts it again (PaimonSinkWriter.java:233). The partitionCustom shuffle itself is the expected, documented cost. No new locks, no unbounded buffers.
1.4 Error Handling and Logging
Failures are typed and name the offending tables. See Issue 2 for the hot-path exception on unknown tables.
Issue 5: incompatible-changes.md (en and zh) now conflicts with dev
- Location:
docs/en/introduction/concepts/incompatible-changes.md:355-358anddocs/zh/introduction/concepts/incompatible-changes.md(same section) - Problem description: GitHub reports the PR as
DIRTY(compare statusdiverged, 4 ahead / 102 behinddev). I ran a three-way merge against currentdev: the only conflicting files are the twoincompatible-changes.mdfiles.devadded the "Behavior change: the REST log-content endpoints return at most 64 MB by default" entry in the same "Engine Behavior Changes" section, and both sides touched the same lines. All source files merge without textual conflicts, and none of the files this PR changes were modified ondevsince the merge base. - Potential risk: the PR cannot be merged until this is resolved, and a careless resolution could drop one of the two entries (this is the item @SEZ9 asked you to re-check after the
devmerge). - Best improvement: please sync with the latest
devand resolve the conflict by keeping both entries; the Paimon entry should be added after the existing REST entry in that section. Then re-run CI. - Severity: High (blocks merge, docs only)
- Raised by another reviewer: Related to @SEZ9's request to re-check the entries after syncing; the conflict itself is new.
Issue 6: the compatibility note does not follow the structure of the neighboring entries
- Location:
docs/en/introduction/concepts/incompatible-changes.md:355-357,docs/zh/introduction/concepts/incompatible-changes.md(same section) - Problem description: every other entry in that file is a bold bullet with
Affected component,Description,ImpactandMigration Guidesub-bullets. This one is a####heading with one prose paragraph, and the migration guidance ("setmulti_table_sink_replica = 1, separate fixed and non-fixed bucket sinks, merge source streams") is mixed into the description. I should have flagged this in my previous round. - Potential risk: low, readers scanning the file for migration steps will miss it, and the heading level is inconsistent.
- Best improvement: while resolving Issue 5, reshape it into the same bullet format (affected component
connector-paimonplus Flink starters, description, impact, migration guide). - Severity: Low (non-blocking)
- Raised by another reviewer: No
Carry-over from my previous review, unchanged on this head: Issue 1 (Medium) double row conversion on the fixed-bucket hot path; Issue 2 (Low) MultiTableWriteRouting.select throws for a table that is not in the routes map (MultiTableSink.java:181-182); Issue 3 (Low) the container E2E only exercises bucket = 1. Issue 4 (the fully-qualified java.util.Optional) is fixed by 682e9259e. All three remaining items are tracked in your PR description's follow-up checklist, which is a reasonable place for them.
2. Code Quality Assessment
2.1 Coding Standards
New public types carry Javadoc and license headers, no wildcard imports. The Optional import now matches the sibling SupportSinkDataPartition.
2.2 Test Coverage and Test Stability
Coverage exercises the real path: MultiTableWriteRoutingTest, SupportSinkDataPartitionTest, PaimonFixedBucketPartitionerTest, SinkWriteRoutingPartitionerTest, a MiniCluster PaimonFlinkBucketRoutingTest against the real processor/factory path, and an extended PaimonIT.
Stability rating: Risk present (unchanged). PaimonFlinkBucketRoutingTest.java:313 uses enableCheckpointing(200) inside three @Timeout(120) MiniCluster cases (lines 98, 139, 156). The waits are bounded polls rather than bare sleeps, so this is not high risk, but a 200 ms checkpoint interval on a loaded shared runner is a plausible source of intermittent timeouts. Suggestion: raise the interval or widen the timeout if it ever flakes. Non-blocking.
2.3 Documentation Updates
en and zh Paimon.md, sink-connector-development.md and incompatible-changes.md are updated together and match the enforced constraints. See Issues 5 and 6 for the remaining docs work.
3. Architectural Soundness
3.1 Precise fix: it moves the capability check to the object that reaches the runtime, on top of the existing SupportSinkDataPartition SPI. 3.2 Maintainability: SinkWriteRoutingPartitioner replaces three copy-pasted inline blocks. 3.3 Extensibility: other sinks with a writer-ownership requirement can adopt the SPI without engine changes. 3.4 Historical-version compatibility: non-routed jobs are unchanged; routed jobs now fail fast where they previously ran unsafely, as documented.
Multi-table SPI contract check (SupportMultiTableSinkWriter): not newly introduced by this PR, and the existing contract still holds: PaimonSink implements SupportMultiTableSink (PaimonSink.java:74), createWriter returns PaimonSinkWriter which implements SupportMultiTableSinkWriter, and PaimonSinkFactory.optionRule() lists MULTI_TABLE_SINK_REPLICA.
4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| 5 | en/zh incompatible-changes.md conflict with dev |
docs/{en,zh}/introduction/concepts/incompatible-changes.md |
High (blocker, docs only) |
| 1 | Full row converted twice per record on the fixed-bucket path | PaimonFixedBucketPartitioner.java:60-63, PaimonSinkWriter.java:233 |
Medium |
| 2 | Unknown-table row throws on the routing hot path | MultiTableSink.java:181-182 |
Low |
| 3 | Container E2E only covers bucket = 1 |
fake_cdc_to_paimon_fixed_bucket_routing.conf |
Low |
| 6 | Compatibility note format differs from neighboring entries | incompatible-changes.md (en/zh) |
Low |
| 4 | Fully-qualified Optional |
SinkDataPartitioner.java |
Fixed in 682e9259e |
5. Merge Recommendation
Conclusion: Ready to merge after fixes
- Blockers - must be fixed: Issue 5 (sync with
devand resolve the two docs conflicts). There is no source-level blocker; my source approval from the previous round still stands for this head. - Recommended fixes - non-blocking: Issue 1 (reuse the converted row or extract only the bucket fields), Issues 2 and 3 as the follow-ups you already listed, Issue 6 while you are editing the same section.
CI on this head, so the next step is clear (fork run 37716867306 on 682e9259e, attempts 1 and 2; attempt 3 was cancelled and the run is currently queued):
paimon-connector-it (8)and(11),engine-v2-it (8)and(11), andunit-teston JDK 8 (ubuntu and windows) and JDK 11 (windows) are green in attempt 2.unit-test (11, ubuntu-latest)failed in both attempts onSavePointTest.testSavePointButJobGoingToFail:87(ConditionTimeout) inseatunnel-engine-server, which this PR does not touch. I read the job logs directly; there is no Paimon,MultiTableSinkor Flink-starter failure.Dead linksfails on the two DeepWiki URLs returning HTTP 429. That is already fixed ondevby #12639 (merged 2026-10-07), so the sync you need for Issue 5 should clear it, since this branch does not contain that commit.
So the lowest-cost next step is: sync with the latest dev, resolve the docs conflict, and rerun CI. If SavePointTest still fails after the sync, please paste the new job link here and I will help narrow it down. Merge state also needs an approving review from an account with write access under the dev ruleset, which my review cannot satisfy.
Overall assessment: the routing fix is correct and well tested on the real Flink path; what remains is the docs conflict with dev and a green rerun. I don't see a better alternative design; hooking into the existing SupportSinkDataPartition SPI at the wrapper level is the right place.
DanielLeens
left a comment
There was a problem hiding this comment.
Thank you again for the patience and for syncing with dev and resolving the docs conflict, @201811510411lw. This is a full re-review of head dc533c7e9 (my previous review was at 682e9259e).
What Problem Does This PR Solve?
Pain point: Paimon fixed-bucket (HASH_FIXED) tables need every row of one physical partition/bucket to be written by one sink subtask. In the real Flink path almost every sink is wrapped in MultiTableSink, and the capability check only looked at the per-table sink, so routing never activated and parallel writers could race on one bucket (#12243).
Fix approach: MultiTableSink now implements SupportSinkDataPartition and resolves one combined policy; SinkWriteRoutingPartitioner (shared by the Flink 1.13/1.15/2.0 starters) applies it with partitionCustom, and schema-control rows keep their schema_subtask_id destination without going through data conversion. Mixed routed/unrouted tables, multi_table_sink_replica != 1, and duplicate physical targets fail at initialization.
One-sentence summary: it moves the routing capability to the object that actually reaches the runtime, so fixed-bucket Paimon writes are owned by exactly one writer.
1. Code Change Review
1.1 Core Logic Analysis
What changed since my last review (682e9259e to dc533c7e9): I diffed every PR-owned file between the two heads. The only PR files that differ are docs/en/introduction/concepts/incompatible-changes.md and docs/zh/introduction/concepts/incompatible-changes.md. All Java, pom, test and E2E files are byte-identical to what I already reviewed. apache/dev (83603e19b) is now an ancestor of the head, so the branch is fully synced and the docs conflict I raised as Issue 5 is resolved. The new entry in both files now uses the same Affected component / Description / Impact / Migration Guide shape as its neighbours, which also closes my earlier Issue 6.
Runtime path (normal streaming path, hit by every HASH_FIXED Paimon job on Flink):
SinkExecuteProcessor.execute()
-> handleSaveMode() (PaimonSink.paimonTable populated via SupportLoadTable)
-> tryGenerateMultiTableSink() -> MultiTableSink(sinks by TablePath)
-> SinkWriteRoutingPartitioner.prepare(ds, sink, parallelism, streaming)
-> SupportSinkDataPartition.resolve(MultiTableSink, parallelism)
-> per table: PaimonSink.getSinkDataPartitioner() (HASH_FIXED only)
-> reject mixed / replica != 1 / duplicate targetIdentifier
-> [schema evolution] SchemaBroadcastExpander (one control row per writer, input parallelism)
-> partitionCustom(RoutingKeySelector -> SinkWriteRoutingPartitioner)
-> [schema evolution] BroadcastSchemaSinkOperator
-> FlinkSink -> MultiTableSinkWriter (1 queue, replica = 1) -> PaimonSinkWriter
Key findings (verified against source at this head):
- Normal path is hit.
MultiTableSink.getSinkDataPartitioner(MultiTableSink.java) is reached throughSupportSinkDataPartition.resolveon the wrapper thatSinkExecuteProcessorreally passes; non-routed sinks reduce to the previousBroadcastSchemaHandlertransform. - Routing key and writer agree.
PaimonSink.getSinkDataPartitionerbuilds the partitioner fromcatalogTable.getTableSchema().toPhysicalRowDataType()andpaimonTable.schema(), which are exactly the two inputsPaimonSinkWriteruses forRowConverter.reconvert(seaTunnelRowType/sinkPaimonTableSchema). So the bucket picked for routing is the bucket the writer will compute. - SupportMultiTableSinkWriter contract holds.
PaimonSinkWriterimplementsSupportMultiTableSinkWriterand does not overrideprimaryKey()(empty), soMultiTableSinkWriter.writedispatches a row to a random queue (random.nextInt(blockingQueues.size())). That would reorder rows of one bucket whenever there is more than one queue per subtask. ThereplicaNum != 1rejection is therefore not just a policy choice but the thing that keeps one queue and one consumer thread per subtask. The check is applied on the resolved routes, uses the wrapper's ownreplicaNum, and runs before any writer is created. Control rows (schema_change_event) are skipped inMultiTableSinkWriter.write, so the zero-field rows never reach per-table conversion. - Skipped (failed-at-init) tables are excluded from the route/unrouted accounting and mapped to subtask 0 in
MultiTableWriteRouting.select, matchingcreateWriter, which also skips them. - Schema-control delivery validates
schema_subtask_idrange and type before routing, andSinkWriteRoutingPartitioner.partitionrejects out-of-range indices, so a bad index fails loudly rather than misrouting.
1.2 Compatibility Impact
Partially incompatible (intentional and documented). Flink jobs on HASH_FIXED Paimon tables now get a shuffle, and three configurations that previously started (and risked bucket corruption) now fail fast at initialization: multi_table_sink_replica != 1, mixed fixed/non-fixed tables in one sink, and several source tables targeting one physical table. All other sinks and bucket modes keep their old path. No checkpoint, state or commit-info serializer changes; SupportSinkDataPartition / SinkDataPartitioner are new additive API. EN and ZH incompatibility notes now match the enforced behavior.
1.3 Performance / Side-Effect Analysis
The partitionCustom network shuffle is expected and documented. The carried-over cost is Issue 1 below: PaimonFixedBucketPartitioner.select converts each row with RowConverter.reconvert, and PaimonSinkWriter.write converts it again, so fixed-bucket tables pay two conversions per record. At very high per-record throughput this is real CPU, but it is bounded (2x of one conversion step, no memory growth) and the author listed it as a follow-up.
1.4 Error Handling and Logging
Initialization errors name the offending tables or the constraint. Runtime validation of control-row destinations is strict. Issues:
- Issue 1 (carryover, Medium, already acknowledged as a follow-up). Location:
PaimonFixedBucketPartitioner.javaselect()andPaimonSinkWriter.javawrite(). Problem: the full row is converted twice per record. Risk: avoidable CPU on the hot path of every fixed-bucket Flink job. Best improvement: compute the bucket from only the key/partition fields (or reuse the converted row downstream). Raised by another reviewer: SEZ9 accepted deferring it. - Issue 2 (carryover, Low, follow-up). Location:
MultiTableSink.javaMultiTableWriteRouting.select. Problem: a row whosetableIdis neither routed nor skipped throwsIllegalArgumentExceptionon the per-record path. Risk: one unexpected table id takes the job down instead of following the failed-table policy. Best improvement: define the behavior for absent tables, consistent withMultiTableSinkWriter. Raised by another reviewer: SEZ9 (accepted as follow-up). - Issue 3 (carryover, Low, follow-up). Location:
fake_cdc_to_paimon_fixed_bucket_routing.conf. Problem: the container E2E only usesbucket = 1, so real multi-writer splitting is covered by the MiniCluster test but not at container level. Risk: low, MiniCluster coverage exists. Best improvement: add abucket > 1case later. - Issue 4 (new, Low). Location:
docs/en/introduction/concepts/incompatible-changes.md, theMigration Guideline of the REST log-endpoint entry (around line 458). Problem: the merge resolution changed that unrelated line's indentation from two to three spaces (- **Migration Guide**became- **Migration Guide**). This is a PR-introduced edit to an entry that belongs to another change, and a three-space bullet can render as a stray nested/lazy item. Risk: cosmetic docs regression, but it also shows up as an unrelated line in the PR diff. Best improvement: restore the original two-space indentation. Raised by another reviewer: none.
2. Code Quality Assessment
2.1 Coding Standards
New public types and the non-trivial methods carry Javadoc that explains the contract (select range, targetIdentifier, why the expander runs at input parallelism). ASF headers are present, no wildcard imports, and the Optional import cleanup that SEZ9 asked for is in. I found no missing-comment issues.
2.2 Test Coverage and Test Stability
Coverage is meaningful: SupportSinkDataPartitionTest and MultiTableWriteRoutingTest for the API contract and rejection rules, PaimonFixedBucketPartitionerTest for same-key-same-owner, SinkWriteRoutingPartitionerTest for expander/selector/partitioner, and PaimonFlinkBucketRoutingTest on a real Flink MiniCluster with Paimon readback across parallelism changes, multiple tables/buckets and control-row delivery, plus the extended PaimonIT. These tests fail if the wrapper stops resolving routing, if the replica/mixed/duplicate checks are removed, or if a control row loses its destination. Stability rating: Risk present (unchanged): the MiniCluster test uses a 200 ms checkpoint interval with a 120 s timeout over a parameterized matrix, which can time out on a loaded shared runner, though waits are bounded polls rather than bare sleeps. The test-scope Flink 1.18.1 dependencies added to connector-paimon/pom.xml are test-only and do not reach the packaged connector.
2.3 Documentation Updates
EN and ZH are both updated (Paimon.md, sink-connector-development.md, incompatible-changes.md) and match the enforced constraints. Only Issue 4 above needs a whitespace fix.
3. Architectural Soundness
3.1 Elegance
Precise fix. The capability is resolved on the wrapper that reaches the runtime, built on the new generic SPI, with no Paimon special-casing in the engine.
3.2 Maintainability
One shared SinkWriteRoutingPartitioner replaces three copies of the schema-broadcast block in the Flink starters.
3.3 Extensibility
Any sink that needs key ownership can implement SupportSinkDataPartition; the wrapper already merges per-table policies.
3.4 Historical-Version Compatibility
Non-fixed-bucket and non-Paimon paths are unchanged, there are no serializer or state changes, and existing configs keep working except the three newly rejected unsafe ones. The PR does not claim rescaling or global-commit recovery guarantees, and the docs say so. Note the routing is Flink-only; Zeta and Spark paths are unchanged and the docs scope it to Flink.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | Row converted twice per record on the fixed-bucket path (follow-up accepted) | PaimonFixedBucketPartitioner.java select(), PaimonSinkWriter.java write() |
Medium |
| 2 | Unknown-table row throws on the routing hot path (follow-up accepted) | MultiTableSink.java MultiTableWriteRouting.select |
Low |
| 3 | Container E2E only covers bucket = 1 (follow-up accepted) |
fake_cdc_to_paimon_fixed_bucket_routing.conf |
Low |
| 4 | Unrelated REST-log entry's Migration Guide indentation changed by the merge |
docs/en/introduction/concepts/incompatible-changes.md (~line 458) |
Low |
Resolved since the last review: docs conflict with dev (old Issue 5), compatibility-note format (old Issue 6), fully-qualified Optional (old Issue 4).
5. Merge Recommendation
Conclusion: Ready to merge
- Blockers: none on the source or docs side. The only open gate is CI.
- Recommended fixes (non-blocking): Issue 4 (restore two-space indentation, a one-line change); Issues 1 to 3 as the follow-ups already tracked in the PR description.
CI state: the fork Build run for this head (38192018935) was still queued when I looked, and the apache-side Build check is in_progress, so there is no result yet. For reference, the previous failures on earlier heads were unrelated to this diff (SavePointTest on JDK 11, a runner shutdown, and DeepWiki 429 dead links, the last already fixed in dev by #12639, which this head now contains). This head is current with dev, so no further sync is needed; please just confirm the run goes green. Merge state is still BLOCKED only because the dev ruleset needs an approving review from an account with write access.
Overall assessment: the routing fix is correct, hits the real execution path, preserves the SupportMultiTableSinkWriter single-queue ordering through the replica check, and is well tested on a real Flink MiniCluster. I don't see a better alternative design.
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for the quick follow-up, @201811510411lw. This is a full re-review of head b43bc2876 (my previous review was at dc533c7e9). The only change between the two heads is a one-line whitespace fix in docs/en/introduction/concepts/incompatible-changes.md, which is exactly the item I asked for.
What Problem Does This PR Solve?
Pain point: Paimon fixed-bucket (HASH_FIXED) tables need every row of one partition/bucket to be written by a single sink subtask. In the real Flink path nearly every sink is wrapped in MultiTableSink, and the capability check only looked at the per-table sink, so routing never activated and parallel writers could race on one bucket (#12243).
Fix approach: MultiTableSink now implements SupportSinkDataPartition and resolves one combined policy. SinkWriteRoutingPartitioner (shared by the Flink 1.13/1.15/2.0 starters) applies it with partitionCustom, and schema-control rows keep their schema_subtask_id destination without going through data conversion. Mixed routed/unrouted tables, multi_table_sink_replica != 1, and duplicate physical targets fail at initialization.
One-sentence summary: it moves the routing capability to the object that actually reaches the runtime, so fixed-bucket Paimon writes are owned by exactly one writer.
1. Code Change Review
1.1 Core Logic Analysis
What changed since my last review: I diffed dc533c7e9..b43bc2876. Exactly one file differs, docs/en/introduction/concepts/incompatible-changes.md, where the Migration Guide bullet of the unrelated REST log-response entry (~line 458) is back to two-space indentation, matching its neighbours. All Java, pom, test, E2E and ZH doc files are byte-identical to what I already reviewed in full. So my previous Issue 4 is resolved, and the analysis below carries over unchanged.
Runtime path (normal streaming path, hit by every HASH_FIXED Paimon job on Flink):
SinkExecuteProcessor.execute()
-> handleSaveMode() (PaimonSink.paimonTable populated via SupportLoadTable)
-> tryGenerateMultiTableSink() -> MultiTableSink(sinks by TablePath)
-> SinkWriteRoutingPartitioner.prepare(ds, sink, parallelism, streaming)
-> SupportSinkDataPartition.resolve(MultiTableSink, parallelism)
-> per table: PaimonSink.getSinkDataPartitioner() (HASH_FIXED only)
-> reject mixed / replica != 1 / duplicate targetIdentifier
-> [schema evolution] SchemaBroadcastExpander (one control row per writer)
-> partitionCustom(RoutingKeySelector -> SinkWriteRoutingPartitioner)
-> [schema evolution] BroadcastSchemaSinkOperator
-> FlinkSink -> MultiTableSinkWriter (1 queue, replica = 1) -> PaimonSinkWriter
Key findings (re-verified at this head):
- The normal path is hit:
SinkExecuteProcessorpasses theMultiTableSinkwrapper, andMultiTableSink.getSinkDataPartitioneris reached throughSupportSinkDataPartition.resolveon exactly that object. Non-routed sinks reduce to the previous broadcast-schema behavior. - The routing key and the writer agree: the partitioner is built from the same physical row type and Paimon table schema that
PaimonSinkWriteruses for conversion, so the bucket chosen for routing is the bucket the writer computes. - The
SupportMultiTableSinkWritercontract holds:PaimonSinkWriterhas noprimaryKey(), soMultiTableSinkWriter.writepicks a random queue. That would reorder rows of one bucket if there were several queues per subtask, so thereplicaNum != 1rejection is what keeps one queue and one consumer thread per subtask. It runs before any writer is created. - Control rows are skipped in
MultiTableSinkWriter.write, and out-of-rangeschema_subtask_idvalues fail loudly in the partitioner instead of misrouting.
1.2 Compatibility Impact
Partially incompatible (intentional and documented). Flink jobs on HASH_FIXED Paimon tables now get a shuffle, and three configurations that previously started (and risked bucket corruption) now fail fast at initialization: multi_table_sink_replica != 1 on a routed sink, mixed routed/unrouted tables in one wrapper, and independent source writers targeting the same physical table. The entry is recorded in incompatible-changes.md (EN and ZH) with a migration guide. No serializer, checkpoint-state or public config-name change; non-Paimon and non-fixed-bucket paths are unchanged.
1.3 Performance / Side-Effect Analysis
One extra network shuffle for fixed-bucket jobs, which is the price of single-owner writes. The row is converted once for bucket selection and once in the writer (Issue 1, accepted as follow-up). The unknown-table throw on the routing hot path is Issue 2 (accepted follow-up). No new threads, no new unbounded buffers, no new retries; resource release is unchanged.
1.4 Error Handling and Logging
Init-time rejections carry table identifiers and the offending option in the message. No exceptions are swallowed. No sensitive data is logged.
Issue 1: Row is converted twice per record on the fixed-bucket path (follow-up accepted)
- Location:
seatunnel-connectors-v2/connector-paimon/.../bucket/PaimonFixedBucketPartitioner.java(select) andPaimonSinkWriter.java(write) - Problem description: The partitioner reconverts each row to Paimon
InternalRowto compute the bucket, and the writer does it again. - Potential risk: Extra CPU/GC on very high-throughput jobs; no correctness impact.
- Best improvement: Track it as the follow-up listed in the PR description (skip per-row work when routing is not required, or reuse the conversion).
- Severity: Medium (non-blocking)
- Raised by another reviewer: No (already acknowledged by you and @SEZ9 as a follow-up)
Issue 2: Row for a table absent from the wrapper throws on the routing hot path (follow-up accepted)
- Location:
seatunnel-api/.../multitablesink/MultiTableSink.java(MultiTableWriteRouting.select) - Problem description: An unknown
tableIdfails the job instead of being handled by a defined policy. - Potential risk: Fails loudly rather than corrupting data, so it is safe, but the behavior is not yet specified or tested.
- Best improvement: Define and test the behavior as already listed in the PR follow-ups.
- Severity: Low (non-blocking)
- Raised by another reviewer: No (accepted follow-up)
Issue 3: Container E2E only covers bucket = 1
- Location:
seatunnel-e2e/.../resources/fake_cdc_to_paimon_fixed_bucket_routing.conf - Problem description: The container-based case does not exercise several buckets with parallel sink writers. Multi-bucket coverage lives in the MiniCluster test (
PaimonFlinkBucketRoutingTest), which does cover it. - Potential risk: Low; the real-engine coverage gap is limited to the container wiring.
- Best improvement: Add the container-based multi-bucket case already listed in the PR follow-ups.
- Severity: Low (non-blocking)
- Raised by another reviewer: No (accepted follow-up)
2. Code Quality Assessment
2.1 Coding Standards
New public types and non-trivial methods have Javadoc explaining the contract, ASF headers are present, no wildcard imports, and the fully-qualified Optional cleanup requested by @SEZ9 is in. I found no missing-comment issues.
2.2 Test Coverage and Test Stability
Coverage is meaningful and would fail on real regressions: SupportSinkDataPartitionTest and MultiTableWriteRoutingTest (rejection rules and API contract), PaimonFixedBucketPartitionerTest (same key, same owner), SinkWriteRoutingPartitionerTest (expander/selector/partitioner), PaimonFlinkBucketRoutingTest on a Flink MiniCluster with Paimon readback across parallelism changes, multiple tables/buckets and control-row delivery, plus the extended PaimonIT. Stability rating: Risk present (unchanged): the MiniCluster test uses a 200 ms checkpoint interval with a 120 s timeout over a parameterized matrix, which could time out on a heavily loaded shared runner, although the waits are bounded polls rather than bare sleeps. The test-scope Flink 1.18.1 dependencies in connector-paimon/pom.xml do not reach the packaged connector.
2.3 Documentation Updates
EN and ZH are both updated (Paimon.md, sink-connector-development.md, incompatible-changes.md) and match the enforced constraints. The earlier indentation nit is fixed.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix. The capability is resolved on the wrapper that reaches the runtime, built on a generic SPI, with no Paimon special-casing in the engine.
3.2 Maintainability
One shared SinkWriteRoutingPartitioner replaces three copies of the schema-broadcast block in the Flink starters.
3.3 Extensibility
Any sink that needs key ownership can implement SupportSinkDataPartition; the wrapper merges per-table policies.
3.4 Historical-Version Compatibility
No state or serializer changes, existing configs keep working except the three newly rejected unsafe ones, and the docs state that the PR gives no rescaling or global-commit recovery guarantees. Routing is Flink-only; Zeta and Spark paths are unchanged.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | Row converted twice per record on the fixed-bucket path (follow-up accepted) | PaimonFixedBucketPartitioner.java select(), PaimonSinkWriter.java write() |
Medium |
| 2 | Unknown-table row throws on the routing hot path (follow-up accepted) | MultiTableSink.java MultiTableWriteRouting.select |
Low |
| 3 | Container E2E only covers bucket = 1 (follow-up accepted) |
fake_cdc_to_paimon_fixed_bucket_routing.conf |
Low |
Resolved since the last review: the Migration Guide indentation in incompatible-changes.md (old Issue 4).
5. Merge Recommendation
Conclusion: Ready to merge
- Blockers — must be fixed: none on the source, test or docs side.
- Recommended fixes — non-blocking: Issues 1 to 3 are the follow-ups already tracked in the PR description; they can land in later PRs.
I also noted that @SEZ9 is fine with keeping this PR scoped to the routing fix (comment of 2026-09-30). I agree with that scoping.
CI state (head b43bc2876): the apache-side Build check is a pointer to the fork run, and the fork run 38197997826 (attempt 2, i.e. a rerun of failed jobs) is not finished. In attempt 1, three jobs failed: all-connectors-it-2 (11), all-connectors-it-2 (17) and engine-v2-it (11), plus all-connectors-it-6 (17). I read the logs of both all-connectors-it-2 jobs in attempt 2: the only failures are CassandraIT.testCassandra:134 and CassandraIT.testCassandraMultiTableSource:144 (expected: <0> but was: <1>, the same test-container index [4] in both JDK 11 and 17). That is a Cassandra container test unrelated to this diff (no Cassandra, Paimon or routing code is touched). A fix for that flake is open as #12732 but is not on dev yet, so syncing will not clear it; please just rerun only the failed jobs once the remaining ones finish (engine-v2-it (11) and all-connectors-it-6 (17) were still running when I looked). If either of those fails in a Paimon, routing or MultiTableSink test, please paste the link and I will dig in.
Upstream sync: compared with dev, the head is diverged (ahead 6, behind 4) with no conflicts reported; the 4 newer dev commits are unrelated to these files, so no sync is required for this review. Merge state is BLOCKED only because the dev ruleset needs an approving review from an account with write access; I only have read access, so this is a technical sign-off from my side rather than a formal approval.
Overall assessment: the routing fix is correct, hits the real execution path, preserves the single-queue ordering needed by SupportMultiTableSinkWriter through the replica check, and is well tested on a real Flink MiniCluster. I don't see a better alternative design. Thanks again for the patience through the iterations!
|
@SEZ9 Thanks for the review. I have completed the requested updates:
The latest CI run for head I compared them with the exact Apache Therefore, these Cassandra failures are pre-existing on The current PR CI result is documented here: |
|
Thanks @201811510411lw for syncing with
So this failure reproduces on the base branch without this PR, and the diff here (Paimon multi-table sink routing) does not touch the Cassandra connector, its E2E module or the Flink container setup. I do not see a source-level blocker from the CI side. Next step: there is nothing to change in this PR for that lane. Please just leave it as is; a rerun of the failed jobs will keep failing until a fix lands on |
…ests (apache#12756) Co-authored-by: JeremyXin <--golbal> (cherry picked from commit 07d6f22)
DanielLeens
left a comment
There was a problem hiding this comment.
Hi @201811510411lw, thank you for picking up the Cassandra fix and keeping this PR moving. I re-reviewed the whole diff at the new head 9b74846d6307. My previous review was at b43bc2876; this is a full re-read, not just the delta. This is static analysis only; I did not run the PR locally.
What Problem Does This PR Solve?
- User pain point: Paimon fixed-bucket (
HASH_FIXED) tables need all rows of one bucket to be written by one sink subtask. On the real Flink path nearly every sink is wrapped inMultiTableSink, and the capability check only looked at the per-table sink, so routing never activated and parallel writers could race on one bucket (#12243). - Fix approach:
MultiTableSinknow implementsSupportSinkDataPartitionand resolves one combined policy; a sharedSinkWriteRoutingPartitionerin the Flink starter applies it withpartitionCustom; schema-control rows keep theirschema_subtask_iddestination without going through data conversion. Mixed routed/unrouted tables,multi_table_sink_replica != 1and duplicate physical targets fail at initialization. - One sentence: the routing capability now lives on the object that actually reaches the runtime, so each fixed bucket is owned by exactly one writer.
- Before / after: Before: two parallel writers could both receive rows of bucket 3 of a
HASH_FIXEDtable through the wrapper and write conflicting files. After: all rows of bucket 3 are shuffled to one subtask.
1. Code Change Review
1.1 Core Logic Analysis
What changed since my last review (b43bc2876..9b74846d6): exactly one commit, 9b74846d6 "[Fix][E2E] Prevent direct memory exhaustion in Flink 1.20 Cassandra tests (#12756)", touching only seatunnel-e2e/seatunnel-e2e-common/.../flink/Flink20Container.java. That commit is the same change as #12756, which is already merged into dev as 07d6f2235, and the file at the PR head has the same git blob id as the file on origin/dev (f412f3c4). So the net diff against dev does not contain it; GitHub's file list will drop it once the branch is synced or merged. Everything else (API, Paimon, Flink starters, tests, docs) is byte-identical to the head I reviewed in full before.
Runtime path (normal streaming/batch path, hit by every HASH_FIXED Paimon job on Flink):
SinkExecuteProcessor.execute()
-> handleSaveMode() (PaimonSink.paimonTable populated via SupportLoadTable)
-> MultiTableSink(sinks by TablePath)
-> SinkWriteRoutingPartitioner.prepare(ds, sink, parallelism, streaming) [SinkWriteRoutingPartitioner.java:48]
-> SupportSinkDataPartition.resolve(MultiTableSink, parallelism)
-> MultiTableSink.getSinkDataPartitioner [MultiTableSink.java:123]
-> per table PaimonSink.getSinkDataPartitioner (HASH_FIXED only) [PaimonSink.java:219]
-> reject duplicate target (:139), mixed routing (:149), replica != 1 (:153)
-> [schema evolution] SchemaBroadcastExpander, forward(), one control row per writer
-> partitionCustom(RoutingKeySelector -> SinkWriteRoutingPartitioner) [:134, :110]
-> [schema evolution] BroadcastSchemaSinkOperator
-> FlinkSink -> MultiTableSinkWriter (one queue because replica = 1) -> PaimonSinkWriter
Key findings (re-verified at this head):
- The normal user path is hit:
SinkExecuteProcessorhands theMultiTableSinkwrapper toprepare, andresolveis evaluated on exactly that object. Sinks without the capability reduce to the previous behavior (schema broadcast only). - The routing key and the writer agree:
PaimonFixedBucketPartitioner.select(:60-62) converts the row with the same physical row type and PaimonTableSchemathe writer uses and calls Paimon's ownFixedBucketWriteSelector, so the owner computed here is the bucket owner Paimon expects. SupportMultiTableSinkWritercontract:PaimonSinkWriterhas noprimaryKey(), soMultiTableSinkWriterpicks a random queue per row. That is only order-safe because thereplicaNum != 1rejection (MultiTableSink.java:153) guarantees one queue and one consumer per subtask; it runs before any writer is created.- Control rows are skipped by
MultiTableSinkWriter.write, and an invalidschema_subtask_idfails loudly inRoutingKeySelector.getKeyinstead of misrouting. - Schema-evolution caveat is stated in the docs: the partitioner keeps its initial schemas, so safe delivery of control rows does not mean online structural DDL is fully supported.
1.2 Compatibility Impact
Partially incompatible, intentional and documented in incompatible-changes.md (en and zh) with a migration guide: Flink jobs on HASH_FIXED Paimon tables now get an extra shuffle, and three configurations that used to start (and could corrupt buckets) now fail at initialization (multi_table_sink_replica != 1 on a routed sink, mixed routed/unrouted tables in one wrapper, independent writers for one physical table). No option name, default, serializer or checkpoint-state format changes. Zeta and Spark paths and non-Paimon sinks are unchanged.
1.3 Performance / Side-Effect Analysis
One extra network shuffle for fixed-bucket jobs, which is the price of single-owner writes. Each row is converted to Paimon InternalRow twice (routing and writer), see Issue 1. The unknown-table throw is on the per-record path but only after a failed hash lookup, see Issue 2. No new threads, unbounded buffers or retries; resource release is unchanged.
1.4 Error Handling and Logging
Initialization rejections name the offending option or tables. Nothing is swallowed and nothing sensitive is logged. Formal issues:
Issue 1: Row is converted twice per record on the fixed-bucket path (follow-up accepted)
- Location:
PaimonFixedBucketPartitioner.java:60-62(select) andPaimonSinkWriter(write) - Problem description: the partitioner reconverts each row to
InternalRowfor bucket selection and the writer converts it again. - Potential risk: extra CPU/GC on very high throughput jobs; no correctness impact.
- Best improvement: the follow-up already listed in the PR description (skip per-row work when routing is not required, or reuse the conversion).
- Severity: Medium (non-blocking)
- Raised by another reviewer: No (acknowledged by you and @SEZ9 as a follow-up)
Issue 2: A row for a table absent from the wrapper throws on the routing hot path (follow-up accepted)
- Location:
MultiTableSink.java:182(MultiTableWriteRouting.select) - Problem description: an unknown
tableIdfails the job instead of following a defined policy. - Potential risk: it fails loudly instead of corrupting data, so it is safe, but the behavior is not specified beyond one assertion.
- Best improvement: define and test it, as already listed in the PR follow-ups.
- Severity: Low (non-blocking)
- Raised by another reviewer: No (accepted follow-up)
Issue 3: The container E2E only covers bucket = 1
- Location:
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-paimon-e2e/src/test/resources/fake_cdc_to_paimon_fixed_bucket_routing.conf - Problem description: the container case does not exercise several buckets with parallel sink writers; multi-bucket coverage is in the MiniCluster test
PaimonFlinkBucketRoutingTest. - Potential risk: low; the gap is limited to the container wiring.
- Best improvement: add the container multi-bucket case already listed in the follow-ups.
- Severity: Low (non-blocking)
- Raised by another reviewer: No (accepted follow-up)
2. Code Quality Assessment
2.1 Coding Standards
ASF headers on all new files, Javadoc on new public types and non-trivial methods that explains the contract, no wildcard imports, and the Optional import cleanup requested by @SEZ9 is in. No missing-comment issues found.
2.2 Test Coverage and Test Stability
Coverage is meaningful and would go red on real regressions: SupportSinkDataPartitionTest and MultiTableWriteRoutingTest (rejection rules, per-table delegation), PaimonFixedBucketPartitionerTest (same key, same owner), SinkWriteRoutingPartitionerTest (expander, selector, partitioner), PaimonFlinkBucketRoutingTest on a Flink MiniCluster with Paimon readback across parallelism changes, multiple tables/buckets and control-row delivery, and the extended PaimonIT. Stability rating: Risk present (unchanged): PaimonFlinkBucketRoutingTest checkpoints every 200 ms (:313) with @Timeout(120) (:98, :139, :156), which could time out on a very loaded shared runner, although the waits are bounded and there is no bare Thread.sleep. The test-scoped Flink 1.18.1 dependencies in connector-paimon/pom.xml do not reach the packaged connector.
2.3 Documentation Updates
EN and ZH are both updated (Paimon.md, sink-connector-development.md, incompatible-changes.md) and match the enforced constraints.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix. The capability is resolved on the wrapper that reaches the runtime, on a generic SPI, with no Paimon special-casing in the API or the starters.
3.2 Maintainability
One shared SinkWriteRoutingPartitioner replaces three copies of the schema-broadcast block in the Flink 1.13/1.15/2.0 starters.
3.3 Extensibility
Any sink that needs key ownership can implement SupportSinkDataPartition; the wrapper merges per-table policies.
3.4 Historical-Version Compatibility
No state or serializer change; existing configs keep working except the three newly rejected unsafe ones. The docs state that the PR gives no rescaling or global-commit recovery guarantees.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | Row converted twice per record on the fixed-bucket path (follow-up accepted) | PaimonFixedBucketPartitioner.java:60, PaimonSinkWriter.java write() |
Medium |
| 2 | Unknown-table row throws on the routing hot path (follow-up accepted) | MultiTableSink.java:182 |
Low |
| 3 | Container E2E only covers bucket = 1 (follow-up accepted) |
fake_cdc_to_paimon_fixed_bucket_routing.conf |
Low |
5. Merge Recommendation
Conclusion: Ready to merge
- Blockers - must be fixed: none on the source, test or docs side.
- Recommended fixes - non-blocking: Issues 1 to 3, which are the follow-ups already tracked in the PR description and agreed with @SEZ9 (comment of 2026-09-30).
Overall assessment: the routing fix is correct, reaches the real execution path, keeps the single-queue ordering that SupportMultiTableSinkWriter needs through the replica check, and is well tested on a real Flink MiniCluster. I do not see a better alternative design.
Existing reviewer intent: @SEZ9 asked for the first-attempt CI explanation, tracking of the follow-ups, the Optional import and a recheck of the incompatible-changes entries; all four are done in the thread and in the head. @SEZ9 said he would do a final pass and move to merge; I agree with that scope.
Upstream sync and CI (head 9b74846d6):
- Compare against
dev:diverged,ahead_by=7,behind_by=31,mergeable_state=blocked(missing approving review, no conflict reported). The branch does not need a sync for this review; the one commit that is not yet on the PR's merge base (9b74846d6) is byte-identical todev. - Fork run
38671284582: attempt 1 cancelled onlyall-connectors-it-6 (11); the apache-sideBuildcheck is stillin_progressbecause attempt 2 is rerunning. The cancelled job hit its 2h30m limit whileFlussSinkITwas running (the log shows it started at 06:11 and nothing finished before the cancel at 07:34), which is a hang in an unrelated connector.paimon-connector-itpassed on JDK 11 and 17, andall-connectors-it-2(JDK 11 and 17), which failed in the Cassandra tests on the previous head, now passes after the #12756 cherry-pick. So the Cassandra failure I described last time is gone. Please only rerun the failed job (all-connectors-it-6 (11)) rather than the whole workflow. - Merge state is
BLOCKEDonly because thedevruleset needs an approving review from an account with write access; this is a technical sign-off from my side, not a formal approval.
Thanks again for the patience through the iterations!
|
The requested CI rerun has completed successfully: https://github.com/201811510411lw/seatunnel/actions/runs/38671284582 The As agreed, the three non-blocking follow-up items will be addressed in subsequent PRs:
Please let me know if any further action is needed for the merge. |
|
Thanks for the contribution. The CI/merge fact in my previous review has changed. The exact-head fork Build is now completed with failure for The Java 11 engine job failed in The unchanged shared engine test and still-open #12316 were rechecked against latest dev. There is no demonstrated merged fix for this checkpoint-handoff signature, so syncing alone is not the answer. Please rerun the failed engine leg and any required cancelled leg, and keep a repeated engine failure with that upstream investigation rather than changing the Flink/Paimon routing in this PR. Comparison against dev is |
|
Following up on my earlier note about the merge conflicts against From what's now on the thread, the sync has been done: the only commit since Two small asks to close this point out:
Nothing else from the merge-conflict point remains open on my side. |
|
@SEZ9 The current I checked the latest |
|
Hi @201811510411lw, thanks for the quick and clear update, and @SEZ9 thanks for the careful follow-up. Your plan sounds right to me. I re-checked the two upstream items you mention: both #12316 and #12313 are still open and not in On SEZ9's question about the merge commit No new code is needed from you right now, and my earlier source-level conclusion is unchanged. When you merge |
|
@DanielLeens Confirmed. I had previously modified the following three files as part of this PR:
The merge commit |
|
Hi @201811510411lw, thank you for confirming this so quickly. Your note that Current state, to keep the plan clear:
Thanks again for keeping this PR focused. |
|
Hi @201811510411lw, one short follow-up so this thread stays current. Since my last note, the Build on the current head
The merge-commit point is settled and no code changes are needed in the meantime. Thanks again for keeping the PR focused. |
|
@SEZ9 I checked Build #27. I will wait for #12316 or #12313 to land in |
|
Hi @201811510411lw, thanks for checking Build #27 and reporting back. Your plan is exactly what I would do: wait for #12316 or #12313 to land in Remaining asks, just so they are explicit:
Nothing else is open from my side. Thanks for keeping this PR focused. |
|
Hi @201811510411lw, a quick update so you can unblock this: #12316, the fix for the Next steps, unchanged from the plan we agreed on:
No code changes are needed in this PR for that failure. Thanks for keeping it focused. |
|
@DanielLeens @SEZ9 The plain merge of the latest Build #28 completed successfully:
The previously failing |
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for the plain dev merge and for confirming the two previously failing/cancelled legs now passed. I re-read the full 23-file current diff and the real wrapper, Flink processor and schema-control paths. The CI fact cited in my earlier review has changed: current-head Build is SUCCESS, so that old failure guidance is withdrawn. No blocking source issue remains. Sorry for missing the optional test-bookkeeping race and field-contract documentation in the earlier review; these are carryovers, not new behavior introduced by this merge.
What Problem Does This PR Solve?
User pain point: Parallel Flink Paimon writers could own the same fixed bucket because the actual sink is a MultiTableSink wrapper that hid the underlying routing capability.
Fix approach: Expose a generic optional routing SPI through the wrapper, use Paimon's fixed-bucket selector and route before schema handling in all three Flink starter implementations.
One-sentence summary: An insert, update and delete for the same physical partition/bucket must reach one sink writer even when source and sink parallelism differ; schema controls still reach every intended subtask.
Review report time: 2026-10-29T12:02:46.108622-04:00. Current head bc4270b53320c83842b07044ec823f5c3e0b31a7; base dev at 886a3ac6e59aad5e46755761cf9fb8ac2a6d3df9. Checks: Signal pull request update=SUCCESS; Build=SUCCESS. Check references: Signal pull request update Build. Compare: diverged, ahead 11, behind 5; merge state blocked / BLOCKED.
1. Code Change Review
1.1 Core Logic Analysis
All 23 changed files were read, including dependency changes and the full MiniCluster/E2E fixtures. MultiTableSink.java:131-207 resolves each active table once, rejects mixed routed/unrouted modes, replicas other than 1 and duplicate physical targets. PaimonSink.java:219-230 creates routing only after loading a HASH_FIXED table; seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/sink/bucket/PaimonFixedBucketPartitioner.java:49-63 reconverts using initial schemas and calls Paimon's FixedBucketWriteSelector. seatunnel-core/seatunnel-flink-starter/seatunnel-flink-starter-common/src/main/java/org/apache/seatunnel/core/starter/flink/execution/SinkWriteRoutingPartitioner.java:51-83,99-152 applies custom partitioning before the schema operator, expands only broadcast controls and preserves validated Long subtask destinations. Flink 1.13/common/2.0 SinkExecuteProcessor implementations all call the same prepare helper. The existing Paimon multi-table contract is complete: Sink implements SupportMultiTableSink, createWriter returns PaimonSinkWriter, writer implements SupportMultiTableSinkWriter and factory optional rules include MULTI_TABLE_SINK_REPLICA.
Before:
DataStream<SeaTunnelRow> ds = stream.getDataStream();
// optional schema transform, then sinkTo(...): wrapper exposed no bucket policyAfter:
ds = SinkWriteRoutingPartitioner.prepare(ds, sink, parallelism, isStreaming);
// resolve wrapper -> table partitioner -> partitionCustom -> schema handler -> sinkToKey Findings
- The normal Flink wrapper path reaches the new routing policy; this is not an unreachable per-connector hook.
- Ordinary data preserves per-source-channel order through one custom partition rather than an earlier rebalance.
- Control rows bypass Paimon data conversion and preserve each schema_subtask_id; duplicate broadcast epochs are handled by the existing schema operator.
- One active route without skipped tables preserves the legacy unknown/empty-ID fallback; multi-route or skipped-table ambiguity fails explicitly.
- No checkpoint serializer/global commit/rescaling protocol is changed; online DDL routing still uses initial schemas.
Complete runtime path
Paimon factory -> PaimonSink loads physical FileStoreTable / optional branch
-> Flink AbstractSinkExecuteProcessor.tryGenerateMultiTableSink -> MultiTableSink wrapper
-> version-specific SinkExecuteProcessor -> SinkWriteRoutingPartitioner.prepare
-> SupportSinkDataPartition.resolve(wrapper, sink parallelism)
-> per-active-table HASH_FIXED policy + physical target exclusivity checks
Data: source channel -> RoutingKeySelector -> source table route -> RowConverter.reconvert
-> Paimon FixedBucketWriteSelector(partition,bucket,writerCount) -> partitionCustom
-> optional BroadcastSchemaSinkOperator -> FlinkSink -> MultiTableSinkWriter single replica queue
-> PaimonSinkWriter -> bucket write -> existing prepare/global commit
Schema: input broadcast -> per-destination zero-field copies -> target-aware custom routing
-> per-subtask schema epoch dedup -> targeted apply row -> existing sink ACK path
Other bucket modes/no routing retain the existing path; recovery/serializer semantics remain unchanged.
The effects depend on the entry and preconditions above. Recovery, batching and connector lifecycle retain their existing contracts unless explicitly described here; source inspection is not runtime proof.
1.2 Compatibility Impact
Partially incompatible. The generic interfaces are additive and serializable partitioners preserve existing sinks by returning Optional.empty. Flink fixed-bucket multi-table configurations with replicas !=1, mixed routing modes or duplicate physical targets now fail at initialization. Both language migration guides say to use one replica, split incompatible sink definitions and merge streams before a shared target. Unknown-ID fallback is intentionally limited and documented. Checkpoint/commit state formats are unchanged; this does not certify rescaling or online schema changes.
1.3 Performance / Side-Effect Analysis
A custom network shuffle is added for ownership-sensitive sinks. Routing lookup is O(1) by source table; policies are built once. Paimon row conversion occurs during partition selection and again during writing, an agreed non-blocking performance follow-up. Control expansion allocates one copy per sink subtask only for schema broadcasts. No per-row table scan, new production executor or retry policy. Single-replica queue ordering and existing resource/commit lifecycle remain intact. Added Flink MiniCluster/client dependencies are test-scoped, not new production dependencies.
1.4 Error Handling and Logging
Invalid parallelism, destination indices, unsafe replica/mixed/duplicate targets and ambiguous table IDs fail explicitly with contextual errors. Skipped table IDs route to the existing skip policy instead of being converted as live data. No new swallowed exception or secret logging was found. Source/target schema snapshots constrain DDL support and should remain explicit in the partitioner documentation.
Issue 1: Wait for source callback bookkeeping before asserting its size
- Location:
seatunnel-connectors-v2/connector-paimon/src/test/java/org/apache/seatunnel/core/starter/flink/execution/PaimonFlinkBucketRoutingTest.java:145-147 - Problem description: fixture.awaitRows returns when committed Paimon rows equal the expected map. completedInitial is populated separately in each source notifyCheckpointComplete at line 571. Sink commit visibility does not establish that every source callback has already updated that map, yet its size is asserted immediately after row visibility.
- Potential risk: A scheduling-dependent assertion failure can occur when the sink commit becomes visible before a source notification finishes. This is a test synchronization gap, not evidence that bucket routing is incorrect; no high-probability failure was established.
- Best improvement / root-cause and location assessment: Include completedInitial.size()==sourceWriters in the same bounded condition as row verification, or await an explicit completion signal from all source callbacks before the size assertion. Keep exact row assertions and condition-based waiting; do not replace them with a fixed sleep.
- Severity: Medium; non-blocking.
- Raised by another reviewer: No.
Issue 2: Document the partitioner's schema and writer-count lifetime
- Location:
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/sink/bucket/PaimonFixedBucketPartitioner.java:34-39 - Problem description: The new sourceRowType, sinkTableSchema, writerCount and selector fields determine ownership and retain the initialization-time schema, but do not explain their lifecycle or invariants. The developer guide states these limits, while the core class only has a one-line summary.
- Potential risk: Future schema/rescaling changes can reuse a stale routing policy without recognizing that it is bound to initial schemas and a particular downstream writer count.
- Best improvement / root-cause and location assessment: Add a focused class/field contract explaining the initial-schema snapshot, positive writer count supplied by resolution, per-record conversion/selector behavior and need to rebuild routing when those inputs change. No online-DDL/rescaling implementation is requested in this PR.
- Severity: Medium; non-blocking.
- Raised by another reviewer: No.
2. Code Quality Assessment
2.1 Coding Standards
The complete changed-file set, imports and removed lines were inspected. No new option, protocol field, public API or connector registration is added. The important behavior and its limits are explained above; test-boundary documentation should explain the regression it protects.
2.2 Test Coverage and Test Stability
Stability rating: Risk present. The API routing tests and SinkWriteRoutingPartitionerTest.java:38-126 are deterministic map/selector/control cases with no sleeps, clocks or ports. seatunnel-connectors-v2/connector-paimon/src/test/java/org/apache/seatunnel/core/starter/flink/execution/PaimonFlinkBucketRoutingTest.java:138-150,373-397,558-575 has the callback-versus-row-visibility gap in Issue 1. Otherwise its source phases use completed checkpoints/latches, bounded condition polling, UUID progress ownership, temporary Paimon files and finally cancellation; PROGRESS entries are removed on fixture close. PaimonIT.java:134-163 extends the existing Flink container path with exact final contents and independent readback; the container lifecycle/host volume ownership was traced rather than assuming an empty AfterEach means leaked engine containers. The local matrix covers multiple tables/partitions/buckets and unequal source/sink parallelism, while the container case deliberately has one bucket and two writers. Crash/recovery/rescaling and multi-bucket container E2E remain unrun/deferred.
Local verification results: exact-head git fetch and isolated review branch seatunnel-review-12366-20261029 created; full git diff 886a3ac6e59aad5e46755761cf9fb8ac2a6d3df9...bc4270b53320c83842b07044ec823f5c3e0b31a7 read (23 files); git diff --check passed; git show, rg and line-numbered source/caller/config/test reads used for the trace above. GitHub changed filenames are reconciled with this local diff before publication. No local compile, Maven verify, unit/IT/E2E, Docker, service or UI execution occurred, as required for this review task. No build/deployment artifact was reused; engine-ui was not built.
2.3 Documentation Updates
Both Paimon sink pages, both developer guides and both incompatible-change entries agree on HASH_FIXED routing, network shuffle, replica/mixed/duplicate restrictions, unknown-ID fallback, schema-control delivery and initial-schema/restore scope. The small internal field contract in Issue 2 complements those user-facing docs.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix.
3.2 Maintainability
Best change-location assessment: The real runtime wrapper must propagate a generic capability, and Flink must apply it before any rebalance; Paimon bucket conversion stays in its connector. Special-casing Paimon in shared engine code or changing global commit protocols is unnecessary. Follow-up optimization can remove duplicate conversion without changing ownership semantics.
3.3 Extensibility
Keep existing connector identities and contracts. Reuse the current boundary and regression fixtures; no shared-framework redesign or unrelated dependency is needed for the behavior reviewed here.
3.4 Historical-Version Compatibility
The generic interfaces are additive and serializable partitioners preserve existing sinks by returning Optional.empty. Flink fixed-bucket multi-table configurations with replicas !=1, mixed routing modes or duplicate physical targets now fail at initialization. Both language migration guides say to use one replica, split incompatible sink definitions and merge streams before a shared target. Unknown-ID fallback is intentionally limited and documented. Checkpoint/commit state formats are unchanged; this does not certify rescaling or online schema changes. This review does not claim an executed upgrade/recovery validation.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | Wait for source callback bookkeeping before asserting its size | seatunnel-connectors-v2/connector-paimon/src/test/java/org/apache/seatunnel/core/starter/flink/execution/PaimonFlinkBucketRoutingTest.java:145-147 |
Medium, non-blocking |
| 2 | Document the partitioner's schema and writer-count lifetime | seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/sink/bucket/PaimonFixedBucketPartitioner.java:34-39 |
Medium, non-blocking |
Completeness check: full diff and affected entry/call chain, failure/resource paths, compatibility, tests and stability, bilingual docs, configuration/registration and current CI/merge gates were inspected before enumerating these findings. No additional finding is reserved for a later round on this version.
Community review reconciliation: I read the existing maintainer review and all discussion/inline activity. I agree with @davidzollo's earlier approval intent on routing correctness and with @SEZ9's acceptance of the scoped follow-ups. Those were tied to older heads and do not substitute for effective approval on this head. The author's plain-merge confirmation and current Build #28 result answer the pending discussion in this consolidated review. Unknown-ID behavior is now explicitly implemented/tested; duplicate conversion and multi-bucket container coverage remain non-blocking. No existing reviewer point receives a duplicate Daniel issue number.
5. Merge Recommendation
Conclusion: Ready to merge
- Blockers — must be fixed: No code-side blocker found. Required current-head CI and effective maintainer review/merge gates must be satisfied.
- Recommended fixes — non-blocking: Issue 1: Wait for source callback bookkeeping before asserting its size; Issue 2: Document the partitioner's schema and writer-count lifetime
Overall assessment: The real runtime wrapper must propagate a generic capability, and Flink must apply it before any rebalance; Paimon bucket conversion stays in its connector. Special-casing Paimon in shared engine code or changing global commit protocols is unnecessary. Follow-up optimization can remove duplicate conversion without changing ownership semantics. Current head bc4270b53320c83842b07044ec823f5c3e0b31a7; base dev at 886a3ac6e59aad5e46755761cf9fb8ac2a6d3df9. Checks: Signal pull request update=SUCCESS; Build=SUCCESS. Check references: Signal pull request update Build. Compare: diverged, ahead 11, behind 5; merge state blocked / BLOCKED. Behind/diverged status alone is synchronization metadata and does not justify a sync-and-rerun instruction. Daniel has READ permission: this COMMENT is a technical conclusion, not an effective APPROVED event or dismissal of historical requested changes. A write-capable maintainer owns final approval/dismissal where required. The previously cited engine-v2-it (11, ubuntu-latest) backpressure failure and cancelled all-connectors-it-3 (17, ubuntu-latest) are now reported passed on this head, and the collected Apache Build is SUCCESS. CI was the only previous blocker, so the technical conclusion changes to source-clear/approval-ready. Daniel has READ permission and this is a COMMENT, not an effective APPROVED/dismissal event; a write-capable maintainer must satisfy the current approval/queue gate. No sync is requested merely for behind metadata. Thanks again; happy to help with the focused next revision.
|
Thanks for keeping this contribution moving. I need to update the merge-gate information on unchanged head Please sync the latest My latest source-level clearance remains unchanged, and Build is green on this existing head. That green result cannot validate a future conflict-resolution commit. The preceding complete source review remains the source assessment; this is a gate clarification, not another full review or a new list of source findings. Current existing-head checks: Build=SUCCESS. Compare |
DanielLeens
left a comment
There was a problem hiding this comment.
Hi @201811510411lw, thank you for the continued work on this fix and for keeping the merges plain so the review history stays intact. I re-read the whole current diff on head 57b700f1559cbae9bd7bec156a4002dd7c589369 (this head is a plain merge of the current dev; it is 0 commits behind dev and mergeable, so the conflict I flagged on the previous head is resolved). The Java code, tests and Paimon docs are byte-identical to the head I cleared last time (bc4270b5), but the merge itself introduced one documentation regression that I only noticed now, listed as Issue 1 below. My two earlier non-blocking points (Issues 2 and 3) are also still open because the code did not change.
What Problem Does This PR Solve?
User pain point: With Flink, a Paimon sink with bucket = N (fixed bucket) is always wrapped in MultiTableSink, which hid the per-table routing capability. Parallel sink writers could therefore receive rows of the same physical bucket and race on it.
Fix approach: Add a generic, optional routing SPI (SupportSinkDataPartition / SinkDataPartitioner), let MultiTableSink combine the per-table policies, let PaimonSink expose Paimon's FixedBucketWriteSelector for HASH_FIXED tables, and apply the policy with partitionCustom in the three Flink starters before the schema operator.
One-sentence summary: Rows of one physical Paimon partition/bucket now always reach the same sink writer, while schema-control rows still reach every intended subtask.
1. Code Change Review
1.1 Core Logic Analysis
Before:
DataStream<SeaTunnelRow> ds = stream.getDataStream();
// optional schema handler, then sinkTo(...): the MultiTableSink wrapper exposed no bucket policyAfter:
ds = SinkWriteRoutingPartitioner.prepare(ds, sink, parallelism, isStreaming);
// wrapper -> per-table partitioner -> partitionCustom -> schema handler -> sinkToKey findings (all verified in the current tree):
MultiTableSink#getSinkDataPartitionerresolves each non-skipped table once, rejects mixed routed/unrouted tables,multi_table_sink_replica != 1and two tables that target the same physical Paimon location. This is the real runtime wrapper, so the policy is reachable on the normal Flink path.PaimonSink#getSinkDataPartitionerreturns a partitioner only when the loaded table isBucketMode.HASH_FIXED; every other bucket mode keeps the old path (Optional.empty()).SinkWriteRoutingPartitioner#prepareroutes before the schema operator, so data rows keep per-channel order, and only schema broadcasts are expanded (one zero-field copy per sink subtask, with a validatedLongschema_subtask_id).- No checkpoint, serializer or global-commit format is changed.
Runtime path:
PaimonSink (HASH_FIXED table loaded) -> Flink SinkExecuteProcessor builds MultiTableSink
-> SinkWriteRoutingPartitioner.prepare -> SupportSinkDataPartition.resolve(wrapper, parallelism)
-> RoutingKeySelector -> RowConverter.reconvert -> FixedBucketWriteSelector.select(row, writers)
-> partitionCustom -> (optional BroadcastSchemaHandler) -> FlinkSink -> MultiTableSinkWriter
-> PaimonSinkWriter -> existing prepareCommit / global commit
1.2 Compatibility Impact
Partially incompatible, and this is documented. Added interfaces are additive. Flink jobs that write a fixed-bucket Paimon table with multi_table_sink_replica != 1, mix fixed and non-fixed sinks in one multi-table sink, or send two source tables to the same physical table now fail at initialization instead of silently racing. The migration guide in both languages explains the remedy. Checkpoint/commit state is unchanged. Online DDL and rescaling are explicitly not covered.
1.3 Performance / Side Effects
A custom network shuffle is added only for ownership-sensitive sinks. Routing lookup is an O(1) map lookup per row, the policy is built once, and the row is converted once for selection and once for writing (a known, agreed follow-up). Test-only Flink dependencies in connector-paimon/pom.xml are test scoped, so nothing new reaches the connector jar.
1.4 Error Handling and Logging
Invalid parallelism, destination index, unsafe replica/mixed/duplicate target and ambiguous table id all fail with contextual messages. Nothing is swallowed and no secrets are logged.
Issue 1: Merge duplicated an existing dev entry in both incompatible-changes.md files
- Location:
docs/en/introduction/concepts/incompatible-changes.md:798anddocs/zh/introduction/concepts/incompatible-changes.md(the added "engine startup log output" entry just after the Paimon entry); the original entry already exists indevatdocs/en/.../incompatible-changes.md:485. - Problem:
git diff dev...headshows a whole "Behavior change: part of the engine startup log output changes" block added by this PR in both languages, while the textSynchronizing existing worker profilesnow appears twice per file (it appears once indev). It looks like a conflict-resolution artifact of the latest merge. It also leaves no blank line before### Transform Changes. - Risk: Users read the same breaking-change note twice, and this PR would "own" a documentation block that belongs to another change. It is docs-only, no runtime effect.
- Best improvement: Remove the duplicated block from both files so the PR only adds its own Paimon routing entry, and keep a blank line before the next heading.
- Severity: Medium (non-blocking).
- Raised by another reviewer: No.
Issue 2: Wait for source callback bookkeeping before asserting its size (carryover from my earlier review)
- Location:
seatunnel-connectors-v2/connector-paimon/src/test/java/org/apache/seatunnel/core/starter/flink/execution/PaimonFlinkBucketRoutingTest.java:145-147 - Problem:
awaitRowsreturns when committed rows match, butcompletedInitialis filled separately in each sourcenotifyCheckpointComplete(line 571). TheassertEquals(sourceWriters, completedInitial.size())right after can run before the last source callback. - Risk: A scheduling-dependent failure of the test, not a routing bug.
- Best improvement: Include
completedInitial.size() == sourceWritersin the same bounded wait as the row check; do not use a sleep. - Severity: Medium (non-blocking).
- Raised by another reviewer: No.
Issue 3: Document the partitioner's schema and writer-count lifetime (carryover)
- Location:
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/sink/bucket/PaimonFixedBucketPartitioner.java:34-39 - Problem:
sourceRowType,sinkTableSchema,writerCountandwriteSelectorfix ownership for the lifetime of the job but carry no comment about being an initialization-time snapshot. - Risk: A later schema-evolution or rescaling change could reuse a stale routing policy unknowingly.
- Best improvement: A short class/field comment: initial-schema snapshot, positive writer count from resolution, rebuild when either changes.
- Severity: Low (non-blocking).
- Raised by another reviewer: No.
Issue 4: Unrelated whitespace edit in a Chinese connector doc
- Location:
docs/zh/connectors/sink/StarRocks.md:308,492 - Problem: The PR strips trailing whitespace on two lines of a file unrelated to Paimon (the lines exist as-is in
dev). - Risk: Only noise in the diff and a possible future conflict.
- Best improvement: Restore the file to the
devversion. - Severity: Low (non-blocking).
- Raised by another reviewer: No.
2. Code Quality
2.1 Coding Standards
Code is clean and the license headers are present. See Issue 3 for the one missing field contract.
2.2 Tests and Stability
Test files: SupportSinkDataPartitionTest, MultiTableWriteRoutingTest, PaimonFixedBucketPartitionerTest, SinkWriteRoutingPartitionerTest, PaimonFlinkBucketRoutingTest (Flink MiniCluster) and the extended PaimonIT with fake_cdc_to_paimon_fixed_bucket_routing.conf. They cover multi-table, multi-bucket, unequal source/sink parallelism and schema controls.
Stability rating: Risk present only because of Issue 2; the rest uses latches, bounded waits and temporary directories. Crash/recovery and rescaling are not covered, as stated in the docs.
2.3 Documentation
English and Chinese Paimon pages, developer guides and migration notes agree with the code (see Issue 1 for the duplicate block).
3. Architectural Soundness
3.1 Fix Level
Precise fix. The wrapper must expose a generic capability and the Flink starter must apply it before any rebalance; the bucket math stays in the Paimon connector.
3.2 Maintainability
The optional SPI is small and reusable by other ownership-sensitive sinks.
3.3 Extensibility
The rule set (single replica, no mixed modes, one owner per physical target) is explicit and easy to extend later.
3.4 Historical Compatibility
Existing sinks return Optional.empty() and behave as before; only the documented fixed-bucket Flink configurations are rejected earlier.
4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| 1 | Duplicate engine-log entry in both incompatible-changes.md |
docs/en/introduction/concepts/incompatible-changes.md:798, zh counterpart |
Medium, non-blocking |
| 2 | Source callback bookkeeping race in test | PaimonFlinkBucketRoutingTest.java:145-147 |
Medium, non-blocking |
| 3 | Missing field contract in partitioner | PaimonFixedBucketPartitioner.java:34-39 |
Low, non-blocking |
| 4 | Unrelated whitespace edit | docs/zh/connectors/sink/StarRocks.md |
Low, non-blocking |
5. Merge Recommendation
Conclusion: Ready to merge after fixes
Blockers (non-CI): none.
CI: the fork's Build for this head is not green yet. Run #30 (workflow_dispatch) was cancelled and another run for the same head is queued. The previous head passed Build (including engine-v2-it and all-connectors-it-3), and this head only adds a merge of dev on top, so no code-level reason for a new failure is known. Please let the queued run finish; if a job fails, rerun only the failed jobs, and tell us which one.
Recommended non-blocking fixes: Issue 1 (please do this one before merge), then Issues 2, 3 and 4.
- docs: 移除 dev 合并重复引入的引擎启动日志 incompatible-changes 条目,中英文各保留一份 - test: 等待所有 source checkpoint callback 完成后再断言 completedInitial 数量 - docs: 补充 PaimonFixedBucketPartitioner 初始 schema 与 writer 数量生命周期说明 - docs: 恢复 StarRocks.md 为 dev 版本,去掉无关行尾空格改动
|
Following up on the CI point from my last comment (Build #27: Since then the head has moved. The automated review reports that Remaining asks on this point:
I'll re-check the PR once the checks on the new head have finished. |
DanielLeens
left a comment
There was a problem hiding this comment.
Hi @201811510411lw, thank you for turning the last round around so quickly. I re-read the current head e060fba2bbaa4608a0c332a6b3951fb8ae62f70d. The only change since my previous review (57b700f1) is commit e060fba2, which touches two docs files, the StarRocks zh doc, one class comment and one test helper. The rest of the 23-file diff is byte-identical to the head I already cleared at source level.
I also need to apologise for one small miss. While re-reading the migration note I noticed that it names the wrong Flink version. I should have caught this in an earlier round, so it is a carryover from my side, not something new you introduced (Issue 1 below, non-blocking).
What Problem Does This PR Solve?
With Flink, a Paimon sink with bucket = N (fixed bucket) is always wrapped in MultiTableSink, which hid any per-table routing. Parallel writers could therefore receive rows of the same physical bucket and race on it. The PR adds an optional routing SPI (SupportSinkDataPartition / SinkDataPartitioner), lets MultiTableSink combine per-table policies, has PaimonSink expose Paimon's FixedBucketWriteSelector for HASH_FIXED tables, and applies the policy with partitionCustom in the Flink starters before the schema operator.
Verification of my previous points on this head
| # | Previous point | Status at e060fba2 |
Evidence |
|---|---|---|---|
| 1 | Duplicated "engine startup log output" entry in both incompatible-changes.md |
Fixed | The PR now adds only the Paimon entry (docs/en/introduction/concepts/incompatible-changes.md:785-797, docs/zh/introduction/concepts/incompatible-changes.md:684-689). Each entry is followed by a blank line before ### Transform Changes and its zh counterpart, and the original dev entry is untouched. |
| 2 | Source callback bookkeeping race in PaimonFlinkBucketRoutingTest |
Fixed | awaitRows(client, sourceWriters) (PaimonFlinkBucketRoutingTest.java:145) now waits in the same bounded 60s loop until progress.completedInitial.size() == expectedCompletedSources (:373-394). The other callers keep the old behaviour through awaitRows(client) -> awaitRows(client, 0). No sleep-based assertion was added. |
| 3 | Missing lifetime contract on PaimonFixedBucketPartitioner |
Fixed | The class Javadoc (PaimonFixedBucketPartitioner.java:30-35) now states that the schemas are initialization-time snapshots, that the writer count must be positive, and that the partitioner must be rebuilt on a schema or writer-count change. |
| 4 | Unrelated whitespace edit in docs/zh/connectors/sink/StarRocks.md |
Fixed | The file is no longer in the PR's changed-file list. |
@SEZ9's CI request (results for engine-v2-it (11) and all-connectors-it-3 (17) on the new head) is answered by the fork run below.
1. Code Change Review
1.1 Core logic
Unchanged since my last full review. Runtime path:
PaimonSink (HASH_FIXED) -> Flink SinkExecuteProcessor builds MultiTableSink
-> SinkWriteRoutingPartitioner.prepare -> SupportSinkDataPartition.resolve(wrapper, parallelism)
-> per-table PaimonFixedBucketPartitioner.select -> partitionCustom
-> (optional BroadcastSchemaHandler) -> FlinkSink -> MultiTableSinkWriter -> PaimonSinkWriter
All three Flink SinkExecuteProcessor copies (13, 20 and common) are wired. The Flink 1.15 starter has no copy of its own and uses the common one.
1.2 Compatibility
Partially incompatible, and documented in both languages: on Flink, fixed-bucket Paimon with multi_table_sink_replica != 1, mixed fixed/non-fixed sinks, or two source tables targeting one physical table now fail at initialization. The checkpoint and commit format is unchanged. The connector-paimon/pom.xml additions are test scoped.
1.3 Side effects
There is one extra network shuffle, and only for ownership-sensitive sinks. The latest commit does not change this.
1.4 Issues
Issue 1: Migration note names a Flink version that does not exist in the starters (carryover, my miss)
- Location:
docs/en/introduction/concepts/incompatible-changes.md:786("the Flink 1.13, 1.15 and 2.0 starters") anddocs/zh/introduction/concepts/incompatible-changes.md:685(same wording) - Problem: The modified starter
seatunnel-flink-20-starterbuilds against${flink.1.20.1.version}(1.20.1, rootpom.xml:102), not Flink 2.0. - Risk: Users may conclude that Flink 1.20 is not affected, or that Flink 2.0 is supported. Docs only, no runtime effect.
- Best improvement: Write "Flink 1.13, 1.15 and 1.20 starters" in both languages.
- Severity: Low (non-blocking).
- Raised by another reviewer: No.
2. Code Quality
2.1 Standards
The new class comment is clear. A minor note: the last commit message is not in English. That is harmless if the PR is squash-merged with its English title, so it needs no action.
2.2 Tests and stability
The tests are the same as before plus the tightened wait. Stability: Stable. The previous risk from Issue 2 is closed, and the fixture uses latches, bounded waits and temporary directories.
2.3 Docs
The English and Chinese Paimon pages, developer guides and migration notes agree with the code, apart from Issue 1.
3. Architecture
This remains a precise fix at the right level. The wrapper exposes a generic optional capability, the Flink starter applies it before any rebalance, and the bucket math stays in the Paimon connector. Existing sinks return Optional.empty() and behave as before.
4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| 1 | "2.0" should be "1.20" in the migration note | docs/en/introduction/concepts/incompatible-changes.md:786, zh :685 |
Low, non-blocking |
5. Merge Recommendation
Conclusion: Ready to merge
- Blockers (non-CI): none.
- CI: the fork's push-triggered Build run 41566466145 (attempt 2) for this exact head succeeded. That includes
engine-v2-it (11)and(17),all-connectors-it-3 (11)and(17),paimon-connector-it (11/17)and all fourunit-testlegs; 85 jobs passed and 11 were skipped. The apache-sideBuildcheck currently shows failure only because it points at the separateworkflow_dispatchrun 41566797610, which was cancelled. That is a pointer artifact, not a test failure. A re-sync of the apache-side check (or a maintainer re-check) should turn it green. - Merge state: mergeable, 5 commits behind
devwith no conflict reported. Required write-maintainer approval is still pending. - Non-blocking: Issue 1, which you are welcome to fold into a final docs touch-up.
Thanks again for the patience across many rounds. This is a careful, well-scoped fix.
|
@SEZ9 Build #31 (attempt 2) succeeded on head In attempt 1, |
|
Thanks for the exact attempt link. This matches the distinction in my review: Build 41566466145 succeeded on this head after the targeted retry, while Apache still points to the separate cancelled dispatch 41566797610. A missing MavenWrapperMain before execution on the earlier attempt is not a failed source assertion, and the successful same-head retry does not require a code change. Please keep the head unchanged for this issue; the remaining action is for a write-capable maintainer to reconcile/adopt the successful run and provide effective approval. No full rerun or drift-only sync is requested. This is an unchanged-head discussion/CI clarification, not another full source review or a claim of local runtime testing. |
|
@SEZ9 @DanielLeens Following up on this PR. The current head has a successful CI rerun documented, and the last review requested keeping the head unchanged. Could you please advise whether any action is still needed from my side, or whether a maintainer can reconcile the successful run and provide the remaining approval? Should I leave the current head unchanged rather than rebase or coordinate changes with #13243? |
|
Hi @201811510411lw, sorry this follow-up sat unanswered. No code action is needed from your side. Please leave the current head
|
|
@SEZ9 Thanks for clarifying. I’ll keep the current head |
|
Thanks for confirming. I still see the successful exact-head fork attempt 41566466145, while the Apache Build check still reflects the cancelled result. Please keep |
|
@201811510411lw Yes, that plan is correct. Please keep What is left sits with the maintainers and is not done yet:
If anything turns out to be needed from you, I will ask explicitly here. Thanks for your patience and for keeping the head stable. |
|
Thanks, @SEZ9. Agreed: keep |
Purpose of this pull request
Address the fixed-bucket routing bug in #12243. Normal Paimon jobs are wrapped in
MultiTableSink, so inspecting only the per-table sink capability does not activate routing on the actual execution path. Parallel writers can then write conflicting changes to the same physical bucket. Schema-control rows also need a destination independent of data conversion.This PR combines the original partitioner/SPI work from #12301 by zhangshenghang with the wrapper, schema-control, and wiring-test fixes discussed in DanielLeens's review. The original contribution is credited with a co-author trailer.
The routing fix is commit
5de24b8cb, originally based on Apachedevat1650a04cd. Two subsequent merge commits,e4418d068and709750af9, synced the branch with newerdev, including the merged #12449 checkpoint-test fix. The routing changes are:SupportSinkDataPartition/SinkDataPartitionercapability through the actualMultiTableSinkand resolve each table's policy once. Reject mixed routing, unsupported replicas, and duplicate physical targets.PaimonFixedBucketPartitionerwith Paimon'sFixedBucketWriteSelectorto route fixed buckets to their owner.schema_subtask_idwithout passing them through row conversion. Expand broadcasts before routing and changing parallelism.This is limited to routing and its regression coverage. It excludes global-commit recovery, new checkpoint-state serializers, and writer/committer rework.
Does this PR introduce any user-facing change?
Yes. Flink automatically activates routing for
HASH_FIXEDPaimon tables, including wrapped single-table jobs. Routed multi-table sinks requiremulti_table_sink_replica = 1; mixed routed/unrouted sinks and independent source writers targeting the same physical table fail at initialization. EN/ZH documentation and incompatibility notes describe these constraints.The partitioner still uses its initial schemas. Safe schema-control delivery does not imply full online structural DDL support. This PR adds no commit-recovery or rescaling guarantees.
How was this patch tested?
Local verification of this branch on JDK 8 / Maven 3.8.8:
PaimonITcompiled. Docker E2E was not run locally.Commands:
mvn -B \ -pl seatunnel-connectors-v2/connector-paimon,seatunnel-core/seatunnel-flink-starter/seatunnel-flink-13-starter,seatunnel-core/seatunnel-flink-starter/seatunnel-flink-15-starter,seatunnel-core/seatunnel-flink-starter/seatunnel-flink-20-starter \ -am -Dskip.spotless=true -DskipIT=true -Dmaven.jar.forceCreation=true \ -DskipUT=false -DskipTests=false -Dmaven.test.skip=false \ -Dsurefire.failIfNoSpecifiedTests=false \ -Dtest=FlinkSinkWriterTest,MultiTableSinkAggregatedCommitterTest,MultiTableSinkCommitterTest,MultiTableSinkTest,MultiTableSinkWriterSchemaChangeBroadcastTest,MultiTableSinkWriterTest,MultiTableWriteRoutingTest,PaimonBucketAssignerTest,PaimonFixedBucketPartitionerTest,PaimonFlinkBucketRoutingTest,PaimonWriteTest,SchemaOperatorTest,SinkWriteRoutingPartitionerTest,SupportSinkDataPartitionTest \ clean verify mvn -B -pl seatunnel-ci-tools -am clean test \ -Dlicense.skipAddThirdParty=true --no-snapshot-updatesRemote CI for the current head
709750af9passed on the second attempt (Build run 36367411220). The local results above remain local verification.Check list
Follow-up work
MultiTableSinkwrapper.