You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bugfix: fix infinite loop on KafkaAdminClient (dpkp#2194)
An infinite loop may happen with the following pattern:
self._send_request_to_node(self._client.least_loaded_node(), request)
The problem happens when `self._client`'s cluster metadata is out-of-date, and the
result of `least_loaded_node()` is a node that has been removed from the cluster but
the client is unware of it. When this happens `_send_request_to_node` will enter an
infinite loop waiting for the chosen node to become available, which won't happen,
resulting in an infinite loop.
This commit introduces a new method named `_send_request_to_least_loaded_node` which
handles the case above. This is done by regularly checking if the target node is
available in the cluster metadata, and if not, a new node is chosen.
Notes:
- This does not yet cover every call site to `_send_request_to_node`, there are some
other places were similar race conditions may happen.
- The code above does not guarantee that the request itself will be sucessful, since
it is still possible for the target node to exit, however, it does remove the
infinite loop which can render client code unusable.
0 commit comments