kirktrue opened a new pull request, #19980:
URL: https://github.com/apache/kafka/pull/19980

   There’s a difference in the two consumers’ `pollForFetches()` methods in 
this case: `ClassicKafkaConsumer` doesn't block waiting for data in the fetch 
buffer, but `AsyncKafkaConsumer` does.
   
   In `ClassicKafkaConsumer.pollForFetches()`, after enqueuing the `FETCH` 
request, the consumer makes a call to `ConsumerNetworkClient.poll()`. In most 
cases `poll()` returns almost immediately because it successfully sent the 
`FETCH` request. So even when the `pollTimeout` value is, e.g. 3000, the call 
to `ConsumerNetworkClient.poll()` doesn't block that long waiting for a 
response.
   
   After sending out a `FETCH` request, `AsyncKafkaConsumer` then calls 
`FetchBuffer.awaitNotEmpty()` and proceeds to block there for the full length 
of the timeout. In some cases, the response to the `FETCH` comes back with no 
results, which doesn't unblock `FetchBuffer.awaitNotEmpty()`. So because the 
application thread is still waiting for data in the buffer, it remains blocked, 
preventing any more `FETCH` requests from being sent, causing the long pauses 
in the console consumer.


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