You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/02/10 05:33:03 UTC

[GitHub] [kafka] chia7712 commented on a change in pull request #10096: KAFKA-12268: Make early poll return opt-in

chia7712 commented on a change in pull request #10096:
URL: https://github.com/apache/kafka/pull/10096#discussion_r573459714



##########
File path: streams/src/main/java/org/apache/kafka/streams/StreamsConfig.java
##########
@@ -1201,6 +1201,9 @@ private void verifyMaxInFlightRequestPerConnection(final Object maxInFlightReque
         // disable auto topic creation
         consumerProps.put(ConsumerConfig.ALLOW_AUTO_CREATE_TOPICS_CONFIG, "false");
 
+        // enable early return on metadata
+        consumerProps.put(ConsumerConfig.LONG_POLL_MODE_CONFIG, ConsumerConfig.LONG_POLL_RETURN_ON_RECORDS);

Review comment:
       It should be `LONG_POLL_RETURN_ON_RESPONSE` rather than `LONG_POLL_RETURN_ON_RECORDS`

##########
File path: clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java
##########
@@ -1236,7 +1243,17 @@ public void assign(Collection<TopicPartition> partitions) {
                 }
 
                 final FetchedRecords<K, V> records = pollForFetches(timer);
-                if (!records.isEmpty()) {
+
+                // We only need to save off the metadata if we are NOT supposed to return early on metadata-only responses
+                if (!longPollExitEarlyOnMetadata) {

Review comment:
       How about updating `nullableSeenMetadata` only if we don't return records?
   ```java
   if (longPollShouldReturn(records)) { 
    ...
   } else {
     if (nullableSeenMetadata == null) {
       nullableSeenMetadata = new HashMap<>(records.metadata());
     } else {
       nullableSeenMetadata.putAll(records.metadata());
     }
   }
   ```
   
   The benefit from above code is that we don't need to handle duplicate metadata which exists on both `FetchedRecords` and `nullableSeenMetadata` when it succeed to get records and metadata in first loop.
    




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

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