kirktrue commented on code in PR #17700:
URL: https://github.com/apache/kafka/pull/17700#discussion_r1919143343


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractFetch.java:
##########
@@ -408,7 +388,21 @@ protected Map<Node, FetchSessionHandler.FetchRequestData> 
prepareFetchRequests()
         long currentTimeMs = time.milliseconds();
         Map<String, Uuid> topicIds = metadata.topicIds();
 
-        for (TopicPartition partition : fetchablePartitions()) {
+        // This is the set of partitions that have buffered data
+        Set<TopicPartition> buffered = 
Collections.unmodifiableSet(fetchBuffer.bufferedPartitions());
+
+        // This is the set of partitions that do not have buffered data
+        Set<TopicPartition> unbuffered = 
Set.copyOf(subscriptions.fetchablePartitions(tp -> !buffered.contains(tp)));
+
+        if (unbuffered.isEmpty()) {
+            // If there are no partitions that don't already have data locally 
buffered, there's no need to issue
+            // any fetch requests at the present time.
+            return Collections.emptyMap();
+        }
+
+        Set<Integer> nodesWithBufferedPartitions = 
nodesWithBufferedPartitions(buffered, currentTimeMs);

Review Comment:
   Done—KAFKA-18571.



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