lianetm commented on code in PR #15375:
URL: https://github.com/apache/kafka/pull/15375#discussion_r1491231865


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/MembershipManagerImpl.java:
##########
@@ -731,10 +729,29 @@ private boolean targetAssignmentReconciled() {
         return currentAssignment.equals(currentTargetAssignment);
     }
 
+    /**
+     * @return True if the member should not send heartbeats, which would be 
one of the following
+     * cases:
+     * <ul>
+     * <li>Member is not subscribed to any topics</li>
+     * <li>Member has received a fatal error in a previous heartbeat 
response</li>
+     * <li>Member is stale, meaning that it has left the group due to expired 
poll timer</li>
+     * </ul>
+     */
     @Override
     public boolean shouldSkipHeartbeat() {
         MemberState state = state();
-        return state == MemberState.UNSUBSCRIBED || state == MemberState.FATAL;
+        return state == MemberState.UNSUBSCRIBED || state == MemberState.FATAL 
|| state == MemberState.STALE;
+    }
+
+    /**
+     * @return True if the member is preparing to leave the group (waiting for 
callbacks), or
+     * leaving (sending last heartbeat). This is used to skip proactively 
leaving the group when
+     * the consumer poll timer expires.
+     */
+    public boolean isLeavingGroup() {
+        MemberState state = state();
+        return state == MemberState.PREPARE_LEAVING || state == 
MemberState.LEAVING;
     }
 
     /**

Review Comment:
   You're right, fixed it here and on the state description, mentioning the 
application poll event, which is really what it takes.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to