Skip to content
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

timeout param is not respected #753

Open
rahav opened this issue Jun 21, 2024 · 1 comment
Open

timeout param is not respected #753

rahav opened this issue Jun 21, 2024 · 1 comment
Labels

Comments

@rahav
Copy link

rahav commented Jun 21, 2024

Expected Behavior

  1. The default timeout is respected.
  2. If specified, the timeout is respected.

Actual Behavior

The computers on which the 3 ZK servers run are deliberately OFF. Run the client from a forth computer.

In the client code, define 3 hosts in the KazooClient() statement. The start() statement that follows, cycles through the hosts in about 5 seconds per host. Not 10 as expected.

Setting the timeout in the call to KazooClient() or start() does not change this duration.

Snippet to Reproduce the Problem

zk = KazooClient(hosts='rpi17.local:2181,rpi18.local:2181,rpi19.local:2181')   # Adding timeout param does not change behavior
zk.start()`   # or zk.start(timeout=15)

Logs with logging in DEBUG mode

Cannot resolve rpi17.local: [Errno 8] nodename nor servname provided, or not known
Cannot resolve rpi18.local: [Errno 8] nodename nor servname provided, or not known
Cannot resolve rpi19.local: [Errno 8] nodename nor servname provided, or not known
Failed connecting to Zookeeper within the connection retry policy.
Traceback (most recent call last):
File "/Users/Dropbox/Idempotent/ZooKeeper/zkMyCli.py", line 441, in
zk.start(timeout=15)
File "/Users/rahav/anaconda3/lib/python3.11/site-packages/kazoo/client.py", line 669, in start
raise self.handler.timeout_exception("Connection time-out")
kazoo.handlers.threading.KazooTimeoutError: Connection time-out

Specifications

  • Kazoo version: 2.10.0
  • Result of pip list command: kazoo 2.10.0
  • Zookeeper version: 3.8.4
  • Zookeeper configuration:
  • Python version: 3.11.5
  • OS: macOS
@StephenSorriaux
Copy link
Member

Hello,

Thank you for the issue.

In the example and logs you've given, I don't think there is any way to get the "10s per host timeout" you would expect with Kazoo as the error you are getting is a DNS error that prevents Kazoo for making a connection since, well, your hostnames cannot be resolved to a valid IP address. Most of the time there is a 5s timeout for resolving a hostname so that's why you are noticing that specific value. You could probably update your system DNS settings to achieve what you want (maybe some options timeout:10 would work).

With Kazoo, you could make use of some KazooRetry() to retry more, for instance:

from kazoo.client import KazooClient
from kazoo.retry import KazooRetry

zk = KazooClient(hosts='rpi17.local:2181,rpi18.local:2181,rpi19.local:2181', connection_retry=KazooRetry(max_tries=-1)) # infinite retries
zk.start(timeout=30) # wait for 30s... or more depending on the number of hosts + DNS setting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants