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
| // 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.
Update lastSend so we can measure connection timeout.
| to = readTimeout - clientCnxnSocket.getIdleRecv(); | ||
| } else { | ||
| to = connectTimeout - clientCnxnSocket.getIdleRecv(); | ||
| to = connectTimeout - clientCnxnSocket.getIdleSend(); |
There was a problem hiding this comment.
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. |
…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 <andor@apache.org>
|
I submitted to master and branch-3.9 branches. Thanks! |
…less connection loss Reviewers: anmolnar Author: kezhuw Closes apache#2058 from kezhuw/ZOOKEEPER-4508-client-side-session-expiration
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/3of 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.