Skip to content
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

Remove idle connections from pool #309

Merged
merged 6 commits into from
Jun 2, 2021

Conversation

jwgcarlson
Copy link
Contributor

The Memcached server can be configured to drop idle connections (via the
idle_timeout option). When this occurs, pymemcache may still try to
use the connection, resulting in MemcacheUnexpectedCloseError. Hence
the need for client-side idle timeout logic.

This change was proposed in #114, but ultimately dropped.
The current PR uses the same approach but differs slightly in the details.

cgordon
cgordon previously requested changes Mar 4, 2021
Copy link
Collaborator

@cgordon cgordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the added functionality, but I want to note the following caveats:

  • Users can still get MemcachedUnexpectedCloseError, even with this change. This is a distributed system, so it will be very easy for the timing to work out such that the connection looks "live" on the client side, but has become "idle" on the server side.
  • Users still need to expect and handle MemcacheUnexpectedCloseError. I'm starting to think, after recent discussions, that we need to provide more guidance for how to do this. There is no way to guarantee that you will never get this exception.

With those caveats, I think this can eliminate some spurious cases of MemcacheUnexpectedCloseError, which should make normal error handling a little more stream-lined.

pymemcache/client/base.py Outdated Show resolved Hide resolved
pymemcache/pool.py Outdated Show resolved Hide resolved
pymemcache/pool.py Show resolved Hide resolved
@jwgcarlson
Copy link
Contributor Author

Thank you for your prompt review, and I apologize for my own delayed response. I agree with all your comments, and I'll work on updating the PR as soon as I find the time.

@jparise
Copy link
Collaborator

jparise commented May 27, 2021

Thank you for your prompt review, and I apologize for my own delayed response. I agree with all your comments, and I'll work on updating the PR as soon as I find the time.

Just wanted to check in and see if you were able to find the time to make these revisions.

The Memcached server can be configured to drop idle connections (via the
`idle_timeout` option). When this occurs, pymemcache may still try to
use the connection, resulting in `MemcacheUnexpectedCloseError`. Hence
the need for client-side idle timeout logic.

This change was proposed in github.com/pinterest#114, but
ultimately dropped. The current PR uses the same approach but differs
slightly in the details.
@jwgcarlson
Copy link
Contributor Author

Just wanted to check in and see if you were able to find the time to make these revisions.

Oops, I definitely forgot about it, but made the requested changes now. Thanks for your patience.

@jwgcarlson jwgcarlson requested a review from cgordon May 28, 2021 01:25
pymemcache/client/base.py Outdated Show resolved Hide resolved
pymemcache/client/hash.py Outdated Show resolved Hide resolved
pymemcache/pool.py Outdated Show resolved Hide resolved
pymemcache/pool.py Outdated Show resolved Hide resolved
@jwgcarlson jwgcarlson requested a review from jparise May 28, 2021 20:18
@jwgcarlson jwgcarlson requested a review from jparise May 28, 2021 21:13
Copy link
Collaborator

@jparise jparise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@cgordon any remaining concerns from your end?

Copy link
Collaborator

@cgordon cgordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jparise jparise merged commit b164be9 into pinterest:master Jun 2, 2021
@jparise
Copy link
Collaborator

jparise commented Jun 2, 2021

Thanks @jwgcarlson!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants