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

   The javadoc for `KafkaConsumer.commitSync` says:
   
   > Note that asynchronous offset commits sent previously with the 
{https://github.com/link #commitAsync(OffsetCommitCallback)}
   > (or similar) are guaranteed to have their callbacks invoked prior to 
completion of this method.
   
   This is not always true in the legacy consumer, when the set of offsets is 
empty, the execution of the commit callback is not always awaited. There are 
also various races possible that can avoid callback handler execution. 
   
   Similarly, there is code in the legacy consumer to await the completion of 
the commit callback before closing, however, the code doesn't cover all cases 
and the behavior is therefore inconsistent. While the javadoc doesn't 
explicitly promise callback execution, it promises "completing commits", which 
one would reasonably expect to include callback execution. Either way, the 
current behavior of the legacy consumer is inconsistent. 
   
   This change proposed a number of fixes to clean up the callback execution 
guarantees:
   
    - We also need to await async commits that are "pending" instead of 
"in-flight", because we do not know the coordinator yet.
    - In close, we need do not only execute the commit listeners of "pending" 
commits, but also those of "in-flight" commits.
   
   ### 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