When the Kafka consumer buffer writeAll call fails (buffer full or circuit
breaker), the consumer now pauses immediately on the first failure and
calls doPoll() on every retry iteration. This keeps the member in the
group by driving the network I/O that reads JoinGroup/SyncGroup responses
and allows the heartbeat thread to function during rebalances.
Previously, the consumer would retry writeAll for maxRetriesOnException
iterations (calculated as max_poll_interval / 2000) with a 1s sleep
between each retry before pausing. During a rebalance, the heartbeat
thread disables itself after JoinGroup and only re-enables when poll()
processes the JoinGroup response. Without poll() being called, the
coordinator's JoinGroup response sits unread in the socket, and after
session.timeout.ms (60s) expires with no heartbeat or SyncGroup, the
coordinator removes the member. The main thread then gets
UNKNOWN_MEMBER_ID on its next poll, triggering another rebalance.
With this fix, poll() is called on every retry, so JoinGroup/SyncGroup
responses are processed promptly and the heartbeat thread stays active.
Rebalances complete in seconds even when the buffer is full.
Also adds doPoll() in the pauseConsumePredicate path so that external
pause conditions (like circuit breaker) also maintain group membership.
Signed-off-by: Taylor Gray <tylgry@amazon.com>
Description
Issues Resolved
Resolves #[Issue number to be closed when this PR is merged]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.