syhily commented on code in PR #20725: URL: https://github.com/apache/flink/pull/20725#discussion_r960298540
########## flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java: ########## @@ -114,7 +135,12 @@ public void addSplitsBack(List<PulsarPartitionSplit> splits, int subtaskId) { // If the failed subtask has already restarted, we need to assign pending splits to it. if (context.registeredReaders().containsKey(subtaskId)) { - assignPendingPartitionSplits(singletonList(subtaskId)); + LOG.debug( + "Reader {} has been restarted after crashing, we will put splits back to it.", + subtaskId); + // Reassign for all readers in case of adding splits after scale up/down. + List<Integer> readers = new ArrayList<>(context.registeredReaders().keySet()); + assignPendingPartitionSplits(readers); Review Comment: Due to [auto-scaling](https://flink.apache.org/2021/05/06/reactive-mode.html#getting-started) the parallelism may be changed over time. This may led to some splits are [reassigned to other reader instance](https://github.com/streamnative/flink/blob/8088a0996ed3d7ac956ee4c10f7cbbc0cd410e0c/flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/assigner/NonSharedSplitAssigner.java#L110). So we shall try to assign the pending splits to all the available reader instance. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org