lianetm commented on code in PR #15869:
URL: https://github.com/apache/kafka/pull/15869#discussion_r1594430619


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:
##########
@@ -1968,7 +1972,7 @@ SubscriptionState subscriptions() {
     }
 
     private void maybeUpdateSubscriptionMetadata() {
-        if (subscriptions.hasPatternSubscription()) {
+        if (subscriptions.hasPatternSubscription() && 
this.mirroredMetadataUpdateVersion < metadata.updateVersion()) {

Review Comment:
   shouldn't we update the `mirroredMetadataUpdateVersion` here, when we know 
that it changed but there is no pattern subscription at that moment? We update 
it whenever there are calls to subscribe that make the subscription change, but 
this path is triggered from the poll regularly, so if we know metadata changed, 
better to update it just for consistency and to have an accurate snapshot (even 
if the user makes no more calls to subscribe)
    ```suggestion
           if (this.metadataVersionSnapshot < metadata.updateVersion()) {
               this.metadataVersionSnapshot = metadata.updateVersion();
               if (subscriptions.hasPatternSubscription()) {
                   updatePatternSubscription(metadata.fetch());
               }
           }
   ```



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to