m1a2st commented on code in PR #23014:
URL: https://github.com/apache/kafka/pull/23014#discussion_r3780353291


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchRequestManager.java:
##########
@@ -69,6 +74,25 @@ protected void maybeThrowAuthFailure(Node node) {
         networkClientDelegate.maybeThrowAuthFailure(node);
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * If any request is in flight, its completion will wake the application 
thread regardless of the outcome, so
+     * no separate bound is needed. Otherwise, if any fetchable partition is 
still not buffered, it was skipped for a
+     * transient reason, such as reconnect backoff or an unknown leader. Since 
nothing else will wake the application
+     * thread in that case, its wait is bounded by {@code retryBackoffMs}.
+     */
+    @Override
+    public long maximumTimeToWait(long currentTimeMs) {
+        if (!nodesWithPendingFetchRequests.isEmpty()) {
+            return Long.MAX_VALUE;
+        }
+
+        Set<TopicPartition> buffered = fetchBuffer.bufferedPartitions();
+        boolean hasUnbufferedFetchablePartition = 
!subscriptions.fetchablePartitions(tp -> !buffered.contains(tp)).isEmpty();
+        return hasUnbufferedFetchablePartition ? retryBackoffMs : 
Long.MAX_VALUE;

Review Comment:
   Yes, this PR introduces a small delay, up to one heartbeat interval, 
compared to the previous behavior of waking immediately. But as you noted, this 
is still within the existing reconciliation contract: callbacks and commits may 
already need to wait until the next poll iteration.



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