leonardBang commented on code in PR #4629:
URL: https://github.com/apache/flink-cdc/pull/4629#discussion_r4679513386
##########
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:
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.
--
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]