loserwang1024 commented on code in PR #4629:
URL: https://github.com/apache/flink-cdc/pull/4629#discussion_r4717677581
##########
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-fluss/src/main/java/org/apache/flink/cdc/connectors/fluss/source/enumerator/FlussSourceEnumerator.java:
##########
@@ -838,20 +884,87 @@ && isCurrentPartitionBucket(split.getTableBucket()))
// This method should only be invoked in the coordinator executor thread.
private void addPartitionSplitChangeToPendingAssignments(
Collection<FlussSplitBase> newPartitionSplits) {
- int numReaders = context.currentParallelism();
+ if (newPartitionSplits.isEmpty()) {
+ return;
+ }
+ int parallelism = context.currentParallelism();
+ Map<Long, int[]> bucketCounts = new HashMap<>();
+ Map<Long, Map<Long, int[]>> partitionBucketCounts = new HashMap<>();
+ for (FlussSplitBase split : newPartitionSplits) {
+ TableBucket bucket = split.getTableBucket();
+ partitionBucketCounts
+ .computeIfAbsent(bucket.getTableId(), ignored -> new
HashMap<>())
+ .computeIfAbsent(bucket.getPartitionId(), ignored -> new
int[parallelism]);
+ }
+ for (int reader = 0; reader < parallelism; reader++) {
+ Set<TableBucket> buckets =
+ new HashSet<>(readerBuckets.getOrDefault(reader,
Collections.emptySet()));
Review Comment:
@leonardBang Thanks for catching this interleaving. I've pushed the fix in
1ca062fc07 and clarified the Javadoc in e8d8ad0a07.
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
`unassignedPendingSplits` with their existing offsets.
`pendingPartitionSplitAssignment` holds splits with selected owners awaiting
delivery.
- During a local restart, `readerBuckets` retains 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).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]