chia7712 commented on PR #16686:
URL: https://github.com/apache/kafka/pull/16686#issuecomment-2406321559

   hi @hachikuji  long time no see :smile: 
   
   > Is the premise of this PR accurate? I think all bets are off if close() is 
interrupted. 
   
   The issue isn't just with interrupted, but also with 
`ConsumerRebalanceListener`. In the classic consumer, 
`ConsumerRebalanceListener` has the following behaviors:
   
   1. The methods `onPartitionsRevoked` and `onPartitionsLost` are always 
executed during shutdown, regardless of timeout or interruption.
   2. `onPartitionsRevoked` and `onPartitionsLost` are executed by the consumer 
thread.
   3. The interrupt signal should propagate to `onPartitionsRevoked` and 
`onPartitionsLost`.
   4. `onPartitionsRevoked` and `onPartitionsLost` are executed before sending 
the `LEAVE_GROUP` request.
   
   > What I would expect is close() sends a message to the background thread to 
initiate shutdown (which should trigger an immediate LeaveGroup if we're in the 
right state). 
   
   This is a good start to simplifying the close method. However, to ensure the 
guarantees mentioned above, the consumer thread and the background thread need 
to communicate multiple times. The following example demonstrates how we 
execute the listener.
   
   ```
   1. consumer thread -> shutdown event
   2. background thread -> check state and then send accurate listener event 
(`onPartitionsRevoked` or `onPartitionsLost`)
   3. consumer thread -> process callback and then send listener complete event
   ...
   ```
   I really like the idea of `ShutdownEvent`, but I'd like to ask a similar 
question to #17353: Do we need to align all behaviors between the classic 
consumer and the async consumer? In this case, it would be simpler if 
`ConsumerRebalanceListener` could be executed by a non-user thread, similar to 
how the producer's callback works.


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