apache error logs get these messages about once every 10 minutes.

PHP Notice:  Memcache::connect() [<a href='memcache.connect'>memcache.connect</a>]: Server fpdpl07 (tcp 11211) failed with: Connection timed out (110) in memcache/dmemcache.inc on line 309

PHP Warning:  Memcache::connect() [<a href='memcache.connect'>memcache.connect</a>]: Can't connect to fpdpl07:11211, Connection timed out (110) in memcache/dmemcache.inc on line 309

Code in question: http://drupalcode.org/viewvc/drupal/contributions/modules/memcache/dmemc...

According to this, wrapping the connection attempt in a try catch block will prevent it from throwing a Notice/Warning.

Comments

mikeytown2’s picture

Status: Active » Needs review
StatusFileSize
new2.82 KB

patch also fixes some white space issues.

jeremy’s picture

Status: Needs review » Needs work

To test, I simply stopped the memached daemon used on my development website.

With the memcache PECL extension, I see PHP errors (watchdog error type 'php') logged with and without the patch, and the 'memcache' watchdog logs are never generated. Thus, this does not appear to be working as intended.

With the memcached PECL extension, I don't see any errors generated when memcached is stopped, with or without this patch.

mikeytown2’s picture

Status: Needs work » Needs review
StatusFileSize
new4.13 KB

alt way to do it; I don't try to catch errors thrown if using memcached. For memcache I utilize track_error and a custom bootstrap watchdog handler because watchdog doesn't work this early in the start up.

mikeytown2’s picture

StatusFileSize
new4.21 KB

nicer interface; auto registers as a shutdown function now.

mikeytown2’s picture

StatusFileSize
new4.21 KB

fix minor white space issue

mikeytown2’s picture

Title: Wrap $memcache->connect & $memcache->addServer in a try catch block. » Catch & report errors thrown by $memcache->connect.
mikeytown2’s picture

This is currently in use on our production boxes; works well.

noslokire’s picture

Thanks, works for me

mikeytown2’s picture

StatusFileSize
new1.42 KB

simplified the patch; also contains a whitespace fix

jeremy’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Needs review » Patch (to be ported)

Thanks for the improvements. It works in my testing, however I also saw errors thrown by ->get() during my testing, so I've added similar logic there.

I ran this through a simpletest regression test, and did performance comparisons before and after the patch to confirm there wasn't a measurable performance hit.

Committed:
http://drupalcode.org/project/memcache.git/commitdiff/26686ad

Needs to be ported to 7.x-1.x.k

catch’s picture

Status: Patch (to be ported) » Fixed

Ported to 7.x and pushed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

enkrypt3d’s picture

Status: Closed (fixed) » Needs review

I tried applying this patch and it failed:

patch -p1 < memcache-1011000-9-D6.patch dmemcache.inc
patching file dmemcache.inc
Hunk #1 FAILED at 342.
1 out of 1 hunk FAILED -- saving rejects to file dmemcache.inc.rej

Does it have to be the module thats currently in use? I'm using php-pecl-memcache-3.0.4-1.el5

I'm having this same issue and its driving me nuts! More info:

CentOS / Drupal 6.15 - 6.22 / Apache 2.2 / Membase 1.7.2 / Mysql 5.5

Thanks!

mikeytown2’s picture

If you use the latest dev version of memcache, this patch is included.
http://drupalcode.org/project/memcache.git/shortlog/refs/heads/6.x-1.x

enkrypt3d’s picture

what is that link? it just looks like a bug list....

I'm not using pconnect now in my dmemcache.inc file - will enabling that fix my timeout issues?

I've been banging my head against the wall on this one... I guess I'll have to update the module entirely then?

Thanks!

mikeytown2’s picture

Link shows what patches have been committed to the 6.x branch of memcache. So you can see that this patch has not been included in a formal release (last one being 6.x-1.9). You can see this patch was committed on 2011-06-14.

enkrypt3d’s picture

Ah ok got it - sorry for all the questions .... one last one! so I Download the snapshot and just replace the dmemcache.inc file on my system with the snapshot? anything else I need to consider? Thanks!

catch’s picture

Status: Needs review » Closed (fixed)

When updating you should update the whole memcache directory. Moving back to fixed.

enkrypt3d’s picture

Thanks - is it required to run update.php when moving to pecl-memcached from pecl-memcache?