Comments (6)
The main reason I didn't account for this was because I assumed that writing to the dead connection would throw a socket error and cause the loop to exit and reconnect. How is the socket closed, yet can be written to for the ping?
from kazoo.
Great question. To be honest, I don't know the answer but that's exactly what's happening. The ZooKeeper logs very clearly state that the connection has been closed, the ephemeral data for that node is gone, but the client doesn't think anything out of the ordinary has happened: no state change, etc.
It's possible that virtualization might have something to do with it (I've seen the issue on EC2). Oddly enough, each time it's happened, the socket does close after 15 minutes -- and seemingly exactly 15 minutes every time.
However, it seems like a ping timeout may be useful in other situations, such as: if the ZooKeeper server is misbehaving (pegged CPU, swapping, etc?). Getting the client onto a healthy node before it's session expires would be great.
from kazoo.
Agreed, if a ping is not returned within (how many seconds exactly?), then the client should close its connection and try to reconnect.
Are you using the 0.9 release, or the latest beta?
In the latest beta, I think the best way to handle this would be for it to set an event when it sends a ping, and clear it when it gets a ping reply. It can check this event to see if a ping was already sent should it time-out in the loop again, and if it hasn't gotten the prior ping raise a ConnectionClosed exception.
from kazoo.
We've been using 1.0b1 and will be submitting a pull request shortly that implements the timeout as you suggested.
The timings: submit ping at 1/3 the timeout interval, expect pong within another 1/3 the timeout interval. If the pong isn't received, you then have 1/3 the timeout interval to connect to another server. This seemed to be the suggested approach on zookeeper-users.
from kazoo.
Let me know if this failed to resolve the issue and I'll reopen. Thanks!
from kazoo.
Cheers Ben, we appreciate it. Will do..
from kazoo.
Related Issues (20)
- Abort in `selector_select` HOT 1
- Make the ReadTheDocs CI check a required check for PR's HOT 1
- New kazoo release to include SSL fixes HOT 4
- Unhandled exception in connection loop when administrator sets system time in past HOT 1
- Documentation of the ZooKeeper wire protocol? HOT 1
- No handlers could be found for logger "kazoo.handlers.threading"
- Switch publishing to using the new Trusted Publishers action HOT 1
- RuntimeError: Invalid error code HOT 5
- KazooClient thread-safety and instance reuse HOT 4
- Zookeeper sequence node overflow causes perpetual re-election HOT 6
- Non-blocking lock acquisition failure can "leak" the ephemeral lock node.
- Zookeeper Server's watch residue
- Connecting to read only zookeeper HOT 1
- Add option to recursively set ACLs
- asyncio support HOT 4
- kazoo/client.py in python2.7 use KazooClient init throw a error HOT 1
- delete() fails with version greater than 2**31-1 HOT 2
- timeout param is not respected HOT 1
- Add support for SNI hostnames
- Connection timeout is not set to client._session_timeout / 1000 / len(client.hosts) in all places HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kazoo.