Xeli commented on a change in pull request #6594: [FLINK-9311] [pubsub] Added 
PubSub source connector with support for checkpointing (ATLEAST_ONCE)
URL: https://github.com/apache/flink/pull/6594#discussion_r257503663
 
 

 ##########
 File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/source/MessageAcknowledgingSourceBase.java
 ##########
 @@ -148,16 +149,12 @@ public void 
initializeState(FunctionInitializationContext context) throws Except
                if (context.isRestored()) {
                        LOG.info("Restoring state for the {}.", 
getClass().getSimpleName());
 
-                       List<SerializedCheckpointData[]> retrievedStates = new 
ArrayList<>();
+                       List<Map<Long, Set<UId>>> retrievedStates = new 
ArrayList<>();
                        for (SerializedCheckpointData[] entry : 
this.checkpointedState.get()) {
-                               retrievedStates.add(entry);
+                               
retrievedStates.add(SerializedCheckpointData.toDeque(entry, idSerializer));
                        }
+                       pendingCheckpoints = 
SerializedCheckpointData.combine(retrievedStates);
 
-                       // given that the parallelism of the function is 1, we 
can only have at most 1 state
 
 Review comment:
   To give some more context for these changes:
   
   The MessageAcknowledingSourceBase can deduplicate messages it has already 
seen because it keeps a list of messageIds. The PubSubSource actually uses this 
too: 
https://github.com/apache/flink/pull/6594/files#diff-5d1317f139d297f4e67ff13defa4d66cR119
   
   The thing is because the list isn't shared and pubsub (nor RabbitMQ afaik) 
won't guarantee the message will be sent to the same taskmanager this 
deduplication will only work with a parallelism of one.
   
   In the case of this pubsub connector we only guarantee `at least once` so we 
like to be able to use a higher parallelism. It still tries to deduplicate but 
it is more of a best effort.
   
   Though this actually does mean that when you're using the pubsub connector 
with a parallelism of 1 it becomes exactly-once.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to