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

   This issue is related to an optimization for offset fetch logic.
   
   When a user calls `Consumer.poll()`, among other things, the consumer 
performs a network request to fetch any previously-committed offsets so it can 
determine from where to start fetching new records. When the user passes in a 
timeout of zero, it's almost always the case that the offset fetch network 
request will not be performed within 0 milliseconds. However, the consumer 
still sends out the request and handles the response when it is received, 
usually a few milliseconds later. In this first attempt, the lookup fails and 
the `poll()` loops back around. Given that this timeout is the common case, the 
consumer caches the offset fetch response/result from the first attempt (even 
though it timed out) because it knows that the next call to `poll()` is going 
to attempt the exact same operation. When it is later attempted a second time, 
the response is already there from the first attempt such that the consumer 
doesn't need to perform a network request.
   
   The existing consumer has implemented this caching in 
[PendingCommittedOffsetRequest](https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java#L132).
 The new consumer has implemented it in 
[CommitRequestManager](https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java#L510).
 The core issue is the new consumer implementation is clearing out the first 
attempt's cached result too aggressively. The effect being that the second (and 
subsequent) attempts fail to find any previous attempt's cached result, and all 
submit network requests, which all fail. Thus the consumer never makes any 
headway.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


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