Skip to content

Delay group coordinator until after bootstrap #2539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions kafka/coordinator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,16 @@ def ensure_coordinator_ready(self, timeout_ms=None):
# so we will just pick a node at random and treat
# it as the "coordinator"
if self.config['api_version'] < (0, 8, 2):
self.coordinator_id = self._client.least_loaded_node()
if self.coordinator_id is not None:
maybe_coordinator_id = self._client.least_loaded_node()
if maybe_coordinator_id is None or self._client.cluster.is_bootstrap(maybe_coordinator_id):
future = Future().failure(Errors.NoBrokersAvailable())
else:
self.coordinator_id = maybe_coordinator_id
self._client.maybe_connect(self.coordinator_id)
continue
continue
else:
future = self.lookup_coordinator()

future = self.lookup_coordinator()
self._client.poll(future=future, timeout_ms=inner_timeout_ms())

if not future.is_done:
Expand Down Expand Up @@ -677,7 +681,7 @@ def _send_group_coordinator_request(self):
Future: resolves to the node id of the coordinator
"""
node_id = self._client.least_loaded_node()
if node_id is None:
if node_id is None or self._client.cluster.is_bootstrap(node_id):
return Future().failure(Errors.NoBrokersAvailable())

elif not self._client.ready(node_id, metadata_priority=False):
Expand Down
Loading