AHeise commented on a change in pull request #17119:
URL: https://github.com/apache/flink/pull/17119#discussion_r701844841



##########
File path: 
flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/reader/split/PulsarOrderedPartitionSplitReader.java
##########
@@ -75,7 +78,30 @@ protected void finishedPollMessage(Message<byte[]> message) {
 
     @Override
     protected void startConsumer(PulsarPartitionSplit split, Consumer<byte[]> 
consumer) {
-        initialStartPosition(split, consumer);
+        MessageId latestConsumedId = split.getLatestConsumedId();
+
+        // Reset the start position for ordered pulsar consumer.
+        if (latestConsumedId != null) {
+            StartCursor startCursor = 
StartCursor.fromMessageId(latestConsumedId, false);
+            TopicPartition partition = split.getPartition();
+
+            try {
+                startCursor.seekPosition(
+                        partition.getTopic(), partition.getPartitionId(), 
consumer);

Review comment:
       In case of restart, isn't `latestConsumedId` always `null`? I thought we 
would update the `startCursor` on checkpoint, such that it should be properly 
initialized in enumerator/reader right?
   

##########
File path: 
flink-connectors/flink-connector-pulsar/src/main/java/org/apache/flink/connector/pulsar/source/enumerator/PulsarSourceEnumerator.java
##########
@@ -148,8 +162,42 @@ public void close() {
      * @return Set of subscribed {@link TopicPartition}s
      */
     private Set<TopicPartition> getSubscribedTopicPartitions() {
-        return subscriber.getSubscribedTopicPartitions(
-                pulsarAdmin, rangeGenerator, context.currentParallelism());
+        int parallelism = context.currentParallelism();
+        Set<TopicPartition> partitions =
+                subscriber.getSubscribedTopicPartitions(pulsarAdmin, 
rangeGenerator, parallelism);
+
+        // Seek start position for given partitions.
+        seekStartPosition(partitions);

Review comment:
       I think this should only be called in `assignPendingPartitionSplits`. 
Now if you have discover enabled, it would actually seek too often.




-- 
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]


Reply via email to