@ -823,7 +823,7 @@ public abstract class AbstractCoordinator implements Closeable {
@@ -823,7 +823,7 @@ public abstract class AbstractCoordinator implements Closeable {
// needs this lock to complete and terminate after close flag is set.
synchronized ( this ) {
if ( rebalanceConfig . leaveGroupOnClose ) {
maybeLeaveGroup ( ) ;
maybeLeaveGroup ( "the consumer is being closed" ) ;
}
// At this point, there may be pending commits (async commits or sync commits that were
@ -840,8 +840,9 @@ public abstract class AbstractCoordinator implements Closeable {
@@ -840,8 +840,9 @@ public abstract class AbstractCoordinator implements Closeable {
/ * *
* Leave the current group and reset local generation / memberId .
* @param leaveReason reason to attempt leaving the group
* /
public synchronized void maybeLeaveGroup ( ) {
public synchronized void maybeLeaveGroup ( String leaveReason ) {
// Starting from 2.3, only dynamic members will send LeaveGroupRequest to the broker,
// consumer with valid group.instance.id is viewed as static member that never sends LeaveGroup,
// and the membership expiration is only controlled by session timeout.
@ -849,7 +850,8 @@ public abstract class AbstractCoordinator implements Closeable {
@@ -849,7 +850,8 @@ public abstract class AbstractCoordinator implements Closeable {
state ! = MemberState . UNJOINED & & generation . hasMemberId ( ) ) {
// this is a minimal effort attempt to leave the group. we do not
// attempt any resending if the request fails or times out.
log . info ( "Member {} sending LeaveGroup request to coordinator {}" , generation . memberId , coordinator ) ;
log . info ( "Member {} sending LeaveGroup request to coordinator {} due to {}" ,
generation . memberId , coordinator , leaveReason ) ;
LeaveGroupRequest . Builder request = new LeaveGroupRequest . Builder ( new LeaveGroupRequestData ( )
. setGroupId ( rebalanceConfig . groupId ) . setMemberId ( generation . memberId ) ) ;
client . send ( coordinator , request )
@ -1088,14 +1090,13 @@ public abstract class AbstractCoordinator implements Closeable {
@@ -1088,14 +1090,13 @@ public abstract class AbstractCoordinator implements Closeable {
markCoordinatorUnknown ( ) ;
} else if ( heartbeat . pollTimeoutExpired ( now ) ) {
// the poll timeout has expired, which means that the foreground thread has stalled
// in between calls to poll(), so we explicitly leave the group.
log . warn ( "This member will leave the group because consumer poll timeout has expired. This " +
"means the time between subsequent calls to poll() was longer than the configured " +
"max.poll.interval.ms, which typically implies that the poll loop is spending too " +
"much time processing messages. You can address this either by increasing " +
"max.poll.interval.ms or by reducing the maximum size of batches returned in poll() " +
"with max.poll.records." ) ;
maybeLeaveGroup ( ) ;
// in between calls to poll().
String leaveReason = "consumer poll timeout has expired. This means the time between subsequent calls to poll() " +
"was longer than the configured max.poll.interval.ms, which typically implies that " +
"the poll loop is spending too much time processing messages. " +
"You can address this either by increasing max.poll.interval.ms or by reducing " +
"the maximum size of batches returned in poll() with max.poll.records." ;
maybeLeaveGroup ( leaveReason ) ;
} else if ( ! heartbeat . shouldHeartbeat ( now ) ) {
// poll again after waiting for the retry backoff in case the heartbeat failed or the
// coordinator disconnected