Repository navigation
[FLINK-41564][pipeline-connector/fluss] Balance source split assignment across partitions - #4629
loserwang1024 wants to merge 3 commits into
Conversation
|
@leonardBang , WDYT? |
| } | ||
| for (int reader = 0; reader < parallelism; reader++) { | ||
| Set<TableBucket> buckets = | ||
| new HashSet<>(readerBuckets.getOrDefault(reader, Collections.emptySet())); |
There was a problem hiding this comment.
Would it make sense to defer owner selection until all reader reports are available?
During a partial recovery, an already scheduled split initialization could complete after addReader() has removed the restarting reader's bucket view but before its ReaderSplitReportEvent is handled. This fallback then treats that reader as having no existing load. handleTableBucketChanges() groups the new splits by owner before assignPendingPartitionSplits() checks allReadersReported(), so waiting for the report only delays delivery; the preselected owners are not recomputed.
I reproduced this interleaving in an enumerator test: with two readers initially owning eight one-bucket partitions each and four new one-bucket partitions, the final distribution is 12:8 rather than 10:10. Deferring owner selection until the restored-split report arrives makes the same test pass.
Could we keep these initialized splits without selecting owners until the reports arrive, while preserving their initialized offsets? It may also be helpful to add a regression test covering initialization completion between re-registration and the restored-split report.
There was a problem hiding this comment.
@leonardBang Thanks for catching this interleaving. I've pushed the fix in 1ca062f and clarified the Javadoc in e8d8ad0.
The change distinguishes initial ownership reconstruction from a local reader restart:
- On startup or enumerator recovery, owner selection waits for every reader's initial report and the first discovery to prune inactive buckets. Initialized and coordinator-restored pending splits stay in
unassignedPendingSplitswith their existing offsets.pendingPartitionSplitAssignmentholds splits with selected owners awaiting delivery. - During a local restart,
readerBucketsretains the enumerator's logical ownership view.addReader()no longer clears it, and later reports from known readers do not overwrite it, since a checkpoint-restored report can omit more recent assignments.addSplitsBack()still returns splits to their original owners. Assignment requires all readers to be registered, but does not require another report from a restarting reader whose ownership is already known. - The new regression test covers initialization completing both before re-registration and between re-registration and the restored-split report. Starting from 8:8 with four new one-bucket partitions produces 10:10. It also checks offset preservation without reinitialization, and verifies that a late report does not skew subsequent assignments (two more partitions produce 11:11).
Focused enumerator and state serializer tests passed on Flink 1.20.3 / Java 11 (19 tests) and Flink 2.2.0 / Java 17 (28 tests).
…nt across partitions
…oss reader restarts Retain logical bucket ownership across local reader restarts and defer owner selection until the initial distribution is known. Preserve initialized offsets and cover initialization around reader re-registration in tests. Generated-by: Codex CLI 0.167.2 AI-Model: gpt-6 AI-Contributed/Feature: 81/81 AI-Contributed/UT: 110/110
Clarify logical bucket ownership, pending split states, and recovery contracts while removing repeated implementation details. Generated-by: Codex CLI 0.167.2 AI-Model: gpt-6 AI-Contributed/Feature: 94/94 AI-Contributed/UT: 0/0
9cecda4 to
e8d8ad0
Compare
…
What is the purpose of this pull request?
Briefly describe the problem this PR fixes or the feature it introduces. Reference Flink JIRA ticket when possible.
Brief change log
List the key changes in this PR.
Verifying this change
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change added tests and can be verified as follows:
...*...*Documentation
Was generative AI tooling used to co-author this PR?