pymemcache icon indicating copy to clipboard operation
pymemcache copied to clipboard

pymemcache fails if resolving the memcached server fails

Open yakirsudry opened this issue 3 years ago • 5 comments

Sometime my memcached server is down. When that happens, resolving its address fails on the following line:

info = s.getaddrinfo(host, port, s.AF_UNSPEC, s.SOCK_STREAM,
                                 s.IPPROTO_TCP)

This crashes pymemcache. What should actually happen is to assume it is down, and just marking that as "missed"

I understand that I can use ignore_exc, but this seems like a much more local thing.

yakirsudry avatar May 16 '21 06:05 yakirsudry

Changing this default behavior now is a backwards incompatible change, so we need to be careful about this one. Can you elaborate on why you don't think ignore_exc is adequate here? Are you asking for the ability to only treat s.getaddrinfo failing as a miss and not other errors?

jogo avatar May 20 '21 19:05 jogo

ignore_exc indeed handles the problem correctly.

But having the server down or unreachable doesn't feel like an "exception". I feel like this specific case should be treated as a simple miss.

I agree that it's not obvious and I'm not sure if everyone will agree with me

yakirsudry avatar May 20 '21 20:05 yakirsudry

There are many use cases where someone would like to monitor if their application isn't able to communicate to memcache instead of silently ignoring it, and treating it like a miss by default can easily mask critical issues.

ignore_exc is already documented in the getting started guide so hopefully that makes it easy for users to choose which behavior they prefer. https://pymemcache.readthedocs.io/en/latest/getting_started.html#best-practices

jogo avatar May 20 '21 20:05 jogo

#307 has some related discussion.

jparise avatar Jun 16 '21 14:06 jparise

@yakirsudry do you have any suggestions on what we can do in while ensuring backwards compatibility

jogo avatar May 31 '22 16:05 jogo