Skip to content

Commit

Permalink
Check for immediate failure when looking up coordinator in heartbeat …
Browse files Browse the repository at this point in the history
…thread (dpkp#1457)
  • Loading branch information
dpkp authored and 88manpreet committed Aug 1, 2018
1 parent c726adc commit ae3c672
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions kafka/coordinator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,21 +940,17 @@ def _run_once(self):
self.disable()
return

# TODO: When consumer.wakeup() is implemented, we need to
# disable here to prevent propagating an exception to this
# heartbeat thread
#
# Release coordinator lock during client poll to avoid deadlocks
# if/when connection errback needs coordinator lock
self.coordinator._client.poll(timeout_ms=0)

if self.coordinator.coordinator_unknown():
future = self.coordinator.lookup_coordinator()
if not future.is_done or future.failed():
# the immediate future check ensures that we backoff
# properly in the case that no brokers are available
# to connect to (and the future is automatically failed).
with self.coordinator._lock:
# TODO: When consumer.wakeup() is implemented, we need to
# disable here to prevent propagating an exception to this
# heartbeat thread
self.coordinator._client.poll(timeout_ms=0)

if self.coordinator.coordinator_unknown():
future = self.coordinator.lookup_coordinator()
if not future.is_done or future.failed():
# the immediate future check ensures that we backoff
# properly in the case that no brokers are available
# to connect to (and the future is automatically failed).
self.coordinator._lock.wait(self.coordinator.config['retry_backoff_ms'] / 1000)

elif self.coordinator.heartbeat.session_timeout_expired():
Expand Down

0 comments on commit ae3c672

Please sign in to comment.