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


##########
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:
   ok ok, agreed.
   
   But we do introduce a difference regarding reconciliations that land when 
there is nothing fetchable and the app thread blocked on the buffer: before 
this PR we would wake right away, so app thread could run the revocation 
callback and ack back. With this PR, no waking, that reconciliation may only 
pick up on the next poll (app will remain blocked for the poll timeout or the 
maximumTimeToWait from the HBMgr, which considers hb interval). Is my 
understanding correct? 
   
   So agree with not changing the boundary, just sharing the diff I see. This 
remains within the contract/behaviour we have that reconciliations really (that 
may start in the background whenever the broker sends an assignment), but may 
need to wait to the next poll (for whatever needs to be from the app, commit, 
callbacks etc).



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