-
Notifications
You must be signed in to change notification settings - Fork 147
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
Fail to close after calling zk.close() when catching error after stop zookeeper #60
Comments
Here is my pull request. Thx |
Thanks for the PR, I will take a look soon |
I think the problem exists in your test method: zk.once('disconnected', function () {
if (!zk.closed) {
zk.close(); self.connect(); self.emit('zkReconnect');
}
}); The |
@YunNeverMore I'm having this same issue, did you figure out on how to solve it? @alexguan How can we now if |
Apply fix for alexguan#60 and alexguan#61
I used kaka-node to connect to kafka. kafka-node use node-zookeeper-client to get connect to zookeeper to get brokers.
For abnormal testing, there will be two zookeeper connection after stop zookeeper and start zookeeper. If repeating these processes again and again, there will be so many connections even more than 100 which leads to zookeeper stuck.
zk.once('disconnected', function () { if (!zk.closed) { zk.close(); self.connect(); self.emit('zkReconnect'); } });
The problem I found is after zk.close(), the socket still does not closed and self.connect() will create another one.
So I tried to figure out the root problem in node-zookeeper-client.
`ConnectionManager.prototype.onSocketClosed = function (hasError) {
var retry = false,
errorCode,
pendingPacket;
};`
the socket will firstly catches error and closed event will be trigger. The 'retry' will be true. It will set state as 'disconnected' which invokes disconnected event for kaka-node to do zk.close(). Then state become 'closing' and then execute this.connect(), which will set state to 'connecting' and retry and retry.
The solution just add checking in the connect. to make sure if state == closing, just do not connect.
`ConnectionManager.prototype.connect = function () {
var self = this;
};`
I will send a pull request for it.
Thanks
The text was updated successfully, but these errors were encountered: