-
Notifications
You must be signed in to change notification settings - Fork 99
refactor: PingingPool pings sessions using SELECT 1 #75
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
Conversation
hengfengli
left a comment
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.
Generally, it looks good to me. Please resolve the comments.
hengfengli
left a comment
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. So when a session is deleted, calling session.ping() will cause a NotFound error, is this right?
Yes. However there seems to be a delay before the error appears. Given the following code, the error only occurs when DELAY is over ~35s |
|
It makes sense. The deletion needs time to be propagated. So if a session is deleted, when we still execute a transaction on it, what will happen then? When it gets a SessionNotFound error, will it try to get a new session? |
Currently, it will not. However, if we keep the |
hengfengli
left a comment
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. So now, pool.get() uses session.exists() to verify the validness of a session instead of session.ping(). Can we leave a comment over there why we don't use session.ping()?
The reason why we don't use session.ping() is that it has a cached/outdated result, which is inaccurate, is this correct?
Good suggestion! Done :)
Yes, the backend uses a cached value which means a delete may have occurred but not propagated yet. |
hengfengli
left a comment
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.
Currently, PingingPool pings sessions in the background by calling
session.exists()which callsGetSession.Using
SELECT 1is preferred and is used in other client libraries such as Go: