Skip to content

Commit

Permalink
fix(core): Revert "Fix possible endless wait in stop() after AUTH_FAI…
Browse files Browse the repository at this point in the history
…LED error (#688)"

This reverts commit 5225b3e.

The commit being reverted here caused kazoo not to empty the send
queue before disconnecting. This means that if a client submitted
asynchronous requests and then called client.stop(), the connection
would be closed immediately, usually after only one (but possibly
more) of the submitted requests were sent. Prior to this, Kazoo
would empty the queue of submitted requests all the way up to and
including the Close request when client.stop() was called.

Another area where this caused problems is in a busy multi-threaded
system. One thread might decide to gracefully close the connection,
but if there is any traffic generated by another thread, then the
connection would end up terminating without ever sending the Close
request.

Failure to gracefully shutdown a ZooKeeper connection can mean that
other system components need to wait for ephemeral node timeouts to
detect that a component has shutdown.
  • Loading branch information
jeblair committed Mar 1, 2024
1 parent b4155ea commit 2fb93a8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion kazoo/protocol/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ def _connect_attempt(self, host, hostip, port, retry):
self.ping_outstanding.clear()
last_send = time.monotonic()
with self._socket_error_handling():
while not self.client._stopped.is_set():
while True:
# Watch for something to read or send
jitter_time = random.randint(1, 40) / 100.0
deadline = last_send + read_timeout / 2.0 - jitter_time
Expand Down
2 changes: 0 additions & 2 deletions kazoo/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ def test_async_auth_failure(self):
with pytest.raises(AuthFailedError):
client.add_auth("unknown-scheme", digest_auth)

client.stop()

def test_add_auth_on_reconnect(self):
client = self._get_client()
client.start()
Expand Down

0 comments on commit 2fb93a8

Please sign in to comment.