Backoff properly in consumer heartbeat thread if no brokers are available
Author: Allen Xiang
Reviewers: Jason Gustafson
Closes from allenxiang/client-heartbeat-fix
@@ -888,9 +888,9 @@ public abstract class AbstractCoordinator implements Closeable {
long now = time.milliseconds();
if (coordinatorUnknown()) {
- if (findCoordinatorFuture == null)
- lookupCoordinator();
- else
+ if (findCoordinatorFuture != null || lookupCoordinator().failed())
+ // the immediate future check ensures that we backoff properly in the case that no
+ // brokers are available to connect to.
AbstractCoordinator.this.wait(retryBackoffMs);
} else if (heartbeat.sessionTimeoutExpired(now)) {
// the session timeout has expired without seeing a successful heartbeat, so we should
