Closed (fixed)
Project:
Memcache API and Integration
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Jun 2010 at 03:09 UTC
Updated:
30 Sep 2011 at 08:41 UTC
Jump to comment: Most recent file
Comments
Comment #1
rjbrown99 commentedI'm getting a different error, same line. Not sure if it's related. I am on 6.x-1.x-dev as of 2010-May-26, with Pressflow 6.16.77, Fedora 11 x86_64, stock memcached-1.2.8, php-pecl-memcache-3.0.4, php 5.2.13.
I have multiple buckets, and I'm getting the same message for different buckets. It has not reset connections that I am aware of and the site seems to be working, just a lot of notices.
My next move is going to be to upgrade memcached to 1.4.5 and move to the php-pecl-memcached-1.0 package.
EDIT: I'm going to start with just migrating to php-pecl-memcached-1.0 and see how that works. I'll report back.
Comment #2
rjbrown99 commentedI upgraded to php-pecl-memcached-1.0 and so far after 1/2 day of work on the site have not seen that error come back even one time. I made no other changes or upgrades, so I'm going to suggest that anyone running into this try upgrading to php-pecl-memcached from php-pecl-memcache.
Comment #3
tobiassjosten commentedI fear we're hijacking this issue but I had the same problem as rjbrown99 and it was solved by switching to php-pecl-memcached (php5-memcached package in Ubuntu).
Comment #4
bleen commentedquick update ...
After updating to 6.x-1.6 I still get the same error that I reported in the original post, however I now get that error on line 102. Again, I suppressed the error with an "@" but I would love for someone who knows this module better than I do to take a look.
Anyone?
Comment #5
bleen commentedI think I may have found some info on this:
http://www.php.net/manual/en/memcache.get.php#86351
Comment #6
bleen commentedI recently installed memcache on a new site and I'm receiving this error periodically on the new site as well
I'm now using 6.x-1.8
My sysadmin tells me this sounds like a persistent connection problem, but I dont know how to test this or debug or even how to tell if we are in fact using a persistant connection.
Comment #7
bleen commenteda similar post on ruby forums ... http://www.ruby-forum.com/topic/194430#847730
Comment #8
bleen commentedSo with some help I think I have finally tracked down the root of this problem. Because the memcache module uses ->connect() to connect to the first memcache server and ->addServer() to connect to subsequent servers you end up with a mismatch of some servers using a persistent connection and some not. This can lead to a connection reset error like the one in the original post. When a connection is reset the cache_get() call may get an empty response which is bad....
This patch allows a user to pick wether to use persistent or non-persistent connections, but most importantly it ensures that whichever a user chooses is used consistently.
Comment #9
rjbrown99 commentedThanks #8, sounds like a very good find. I popped in the patch tonight with $conf['memcache_persistent'] = TRUE; in settings.php. I'll let you know how it goes.
Comment #10
catchtypo for connect.
Patch looks good otherwise.
Comment #11
catchBenchmarks:
Current dev:
Patch no longer applied, so attaching re-roll, will include benchmark results with the patch (persistent connections and not) next followup.
Comment #12
catchWith the patch, I'm testing with a single memcache server, so it should be exactly the same with the default setting, however it's not:
Current dev:
Patch and default setting (not persistent connections) - not what I expected:
Patch and persistent connections:
So there's a bug in the non-persistent code flow somewhere, I think this patch might do it.
Comment #13
catchThat didn't fix it, I still get this:
Updating latest tidied up version of the patch, but looks like this needs work.
Comment #14
catchAlright not sure what was going on there, but this one works fine:
Back to CNR.
The performance here with and without persistent connections is about the same, it's possible that a different load test plan would show a difference, but the fact there's no obvious change either way (short of my weird results earlier) makes me think we could commit this happily enough.
It may be we'd see a bigger performance change with multiple connections and/or longer load tests - since 5 connections per request * 1000 requests you'd save 4955 connections with persistent connections on.
Comment #15
bleen commentedwording got messed up here
Powered by Dreditor.
Comment #16
bleen commentedComment #17
bleen commentedI think this should be
elseif (!$memcache_persistent && $memcache->connect($host, $port)) {Because if a user has set memcache_persisitent == TRUE && put ->pconnect() fails for some reason we do not want ->connect() to run ... right?
Powered by Dreditor.
Comment #18
catchThat's a good point, adding just that one change.
Comment #19
bleen commentedI'm happy with #18 ...dont suppose I can mark it as RTBC though :)
Comment #20
catchI'm going to mark this RTBC, but I'm offline the next 3-4 days so will leave it there for Jeremy to decide whether to commit.
Comment #21
jeremy commentedAgreed that this patch is fixes a big when using the Memcache PECL extension, as addServer() defaults to TRUE for persistent connection [1], while we are using connect and not pconnect for the initial connection. Researching persistent connections an re-running load tests, I agree with the choice to keeping persistent connections disabled by default (as it can result in memcache running out of available connections the memcache server isn't tuned on busy websites).
The patch is wrong when using the Memcached PECL extension, however. For the Memcached extension, the addServer() parameters change [2] so with this patch we end up adjusting the 'weight' parameter instead of enabling persistent connections. Further research online suggests that support for persistent connections is buggy in the Memcached extension, and reading these docs and the comments below it's a little confusing [3] which has led some to erroneously report memory leaks [4].
[1] http://php.net/manual/en/memcache.addserver.php
[2] http://php.net/manual/en/memcached.addserver.php
[3] http://www.php.net/manual/en/memcached.construct.php
[4] http://pecl.php.net/bugs/bug.php?id=16740
I'm thinking it may be best to simply document that this is a Memcache PECL extension only option for now, and to revisit adding support for persistent connections with the Memcached PECL extension at a later time. This allows us to fix the bug that was initially reported in this issue without getting hung up on adding a new feature.
Comment #22
jeremy commentedI updated the patch to work with both PECL extensions, and documented the fact that we currently only support persistent connections with the Memcache PECL extension. Committed, thanks for tracking this bug down!
http://drupalcode.org/project/memcache.git/commitdiff/3eaa8f8
The new memcache_admin statistics screen was very helpful in confirming that we were properly enabling/disabling persistent connections (as the total # of connections only increases when persistent connections are disabled).
Comment #23
catchThis has been pulled into 7.x