-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
ZOOKEEPER-4508: Expire session in client side to avoid endless connection loss #2058
ZOOKEEPER-4508: Expire session in client side to avoid endless connection loss #2058
Conversation
e315a11
to
51fbf2d
Compare
Mail thread for the proposal: https://lists.apache.org/thread/0hf81c1tdsp6mm130gw1h5xglkx48vv0 |
IIUC, for zookeeper, session expiration is a serious problem. Zookeeper's tutorial recommends shutting down directly after session expiration (if I understand it wrong, please correct me in time). Another point, I am not very clear about your proposal, how to deal with the client session after it expires. If the session is re-created, can we compare the advantages and disadvantages of re-creating the session and renewSession? |
@kezhuw This one looks really cool. Want to see this in 3.9.3? |
…tion loss ZooKeeper session will expire approximately after negotiated session timeout. Currently, client will learn this after successful contact to ZooKeeper cluster. This exposes an endless client side connection loss when client can't reach ZooKeeper cluster due to either incomplete connection string or whole cluster downtime. This pr proposes to introduce a client side session expiration timeout to deal with this. The client side timeout will be approximately `4/3` of server side counterpart, so it can tolerate small skew.
51fbf2d
to
72ffe96
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few questions.
@@ -1143,7 +1152,7 @@ public void run() { | |||
startConnect(serverAddress); | |||
// Update now to start the connection timer right after we make a connection attempt | |||
clientCnxnSocket.updateNow(); | |||
clientCnxnSocket.updateLastSendAndHeard(); | |||
clientCnxnSocket.updateLastSend(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update lastSend
so we can measure connection timeout.
@@ -1181,16 +1190,24 @@ public void run() { | |||
} | |||
to = readTimeout - clientCnxnSocket.getIdleRecv(); | |||
} else { | |||
to = connectTimeout - clientCnxnSocket.getIdleRecv(); | |||
to = connectTimeout - clientCnxnSocket.getIdleSend(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old code is source of confusion. In path of old code, we have to update lastHeard
.
@anmolnar Thank you for your reviewing! I have replied your comments and updated fixup commits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
…tion loss Reviewers: anmolnar Author: kezhuw Closes #2058 from kezhuw/ZOOKEEPER-4508-client-side-session-expiration (cherry picked from commit 8900618) Signed-off-by: Andor Molnar <[email protected]>
I submitted to master and branch-3.9 branches. Thanks! |
ZooKeeper session will expire approximately after negotiated session timeout. Currently, client will learn this after successful contact to ZooKeeper cluster. This exposes an endless client side connection loss when client can't reach ZooKeeper cluster due to either incomplete connection string or whole cluster downtime.
This pr proposes to introduce a client side session expiration timeout to deal with this. The client side timeout will be approximately
4/3
of server side counterpart, so it can tolerate small skew.History
At least four jira issues reported the behavior.
This pr superceded #1847. I did not aware of the fact that ZooKeeper does not have a client side expiration timeout at that time. I will send a proposal email to dev mailing list for discussion soon.