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
Fixed #11331 -- Removed disconnect_all() from pylibmc backend #4866
Conversation
This in reference to django#11331. `libmemcached` manages its own connections fairly well.
Patch needs a test, I suppose and it might be worth mentioning in the release notes for 1.9 |
It's hard to test failure behavior, I suppose it'd be possible but it seems like too big an undertaking for me. I'll be running with this modification in a production system before the end of the week, will let you know about any catastrophic failures. 😜 As for the release notes, do you want to write something or should I? |
Any update on this? |
Well I don't have the time anymore, it's up to you guys. I for one think a test for this is nigh impossible to construct. Cheerio! 🍒 |
Okay, we'll see if anyone comes along to finish it, thanks. |
If a test is hard/not possible, could we not just merge this - and land a changelog entry along with it? :-) |
I agree with @edmorley , seems really stupid to throw away useful code like this, but that's not my job I guess. |
The code's not thrown away, it's sitting right here. Anyone who cares about it is free to finish the pull request by writing a test (or present actual evidence that a test is not feasible). We don't merge code in Django without tests just because the original contributor didn't feel like writing one. |
If a normal test isn't feasible, it might be possible to use |
Well, the code is tested by the usual caching tests so I don't understand what needs to be tested. I also think you should refrain from formulations such as "We don't merge code in Django without tests just because the original contributor didn't feel like writing one", IMHO it creates a hostile environment. |
@lericson Sorry for that formulation. ISTM the hostile environment was created by "seems really stupid to..." |
Well, you are burying a fix I made that others would almost certainly appreciate to have as well, so yes I guess I'm feeling a little pissy about it. The code is run by tests, not specifically testing disconnecting behavior but at least exercising the code path. You're free to reject my contributions on purely bureaucratic grounds, of course, but I think that's a slippery slope no maintainer should ever go down.
|
From the perspective of a maintainer, accepting contributions without tests is a slippery slope. :-) If you have time to continue this discussion, why not spend a few minutes trying to write a test instead. This is how we keep Django high-quality and help to prevent regressions. |
I’ve said it three and a half times now, so I won’t bore you with further discussion but let it be known without doubt that THE CODE IS EXERCISED IN TESTS. Have a good one.
|
Currently, Django disconnects from the cache on at the end of every HTTP request. This is a significant performance problem as it mangifies the number of round trip times (each connection requires a VERSION command, and if authenticating a LIST_MECHS and an AUTH command before any real work can be done) and incurs the cost of TCP startup every time. There has been a long and slow push to get this fixed upstream in Django (https://code.djangoproject.com/ticket/11331, django/django#4866), but it's a simple enough fix to do at the higher level library.
@lericson I'm happy to take over this pull request. We've been promoting a monkey patch to our customers that basically does this for several years and it seems like the best solution without other pretty significant change to the Django caching infrastructure. @timgraham Do you think using |
Yes, something like that -- I haven't looked at the details. As long as the test fails before patch and passes afterward it should be a good start at least. |
I'm going to open a new PR for this, but have a query as to whether third party backends should stop using disconnect_all() after every request too - see: @jaysonsantos / @alevy , would you happen to know the answer for jaysonsantos/python-binary-memcached? Many thanks :-) |
@edmorley On jaysonsantos/python-binary-memcached we don't have a connection pool, in this case if you have a broken connection it would sit there forever. We have a issue that needs to be implemented that is the consistent hashing (when I created it I was mimicking django abstraction to replicate all the keys) and with it we would have a connection pool and we would manage it and reconnect if needed. |
I am inheriting the project, and didn't write the original code, so I could be wrong, but I believe that pymemcache doesn't close on every connection, but whenever one of the exceptions we have created gets raised. |
@nichochar is correct about the behavior of pymemcache. The documentation for the |
So it sounds like it's a mixed bag - and as such the Django base memcached class should probably assume the client doesn't manage its own connections until proven otherwise. (And I'll just special-case the pylibmc backend for now). Many thanks! |
This in reference to #11331.
libmemcached
manages its own connections fairly well.