Initiate Coordinator Reconnect w/ Backoff from Heartbeat Thread #2695
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Attempt to fix issue raised in #2672 and possibly also #2667
If the coordinator node becomes unresponsive it can cause the consumer to busy-loop until the next attempt to reconnect to the coordinator. This happens when there is no pending request to the coordinator node itself (either a heartbeat or commit) when the broker connection fails. If the consumer is configured with auto-commits then the next commit attempt will see the coordinator failure, mark the coordinator dead, and the consumer loop will revert to waiting for the coordinator to return. But if auto-commits are disabled, the heartbeat thread will be in a limbo state where it thinks the coordinator is connecting and pauses heartbeat request. With neither a failed connection attempt or a failed heartbeat request, the coordinator is never marked dead and the consumer busy loops. To fix, this patch adds an explicit connection attempt to the heartbeat thread loop whenever the coordinator is known but disconnected. If the connection fails the client will mark the node as disconnected and add a backoff reconnect delay. The non-zero backoff delay causes the consumer to mark the coordinator dead, which prevents the busy loop.