Skip to content

PHP crash in get() when using persistence #59

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

Closed
doapp-ryanp opened this issue Jan 19, 2013 · 1 comment
Closed

PHP crash in get() when using persistence #59

doapp-ryanp opened this issue Jan 19, 2013 · 1 comment

Comments

@doapp-ryanp
Copy link
Contributor

I am getting intermittent problems when doing a get() - every few hundred requests PHP is crashing. I've narrowed it down to to a libmemcached/io.cc: No such file or directory error - but I only get this when PHP crashes. About 1% of my requests result in the crash (which caues HTTP 502).

My environment:
Ubuntu 12.04 64bit: Linux ryan 3.2.0-35-generic #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 x86_64
nginx 1.2.4
php5-fpm:

/usr/sbin/php5-fpm -v
PHP 5.3.10-1ubuntu3.4 (fpm-fcgi) (built: Sep 12 2012 19:03:32)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Suhosin v0.9.33, Copyright (c) 2007-2012, by SektionEins GmbH

PECL memcached 2.1.0:

memcached

memcached support => enabled
Version => 2.1.0
libmemcached version => 1.0.15
Session support => yes
igbinary support => yes
json support => no

Directive => Local Value => Master Value
memcached.compression_factor => 1.3 => 1.3
memcached.compression_threshold => 2000 => 2000
memcached.compression_type => fastlz => fastlz
memcached.serializer => igbinary => igbinary
memcached.sess_binary => 0 => 0
memcached.sess_lock_wait => 150000 => 150000
memcached.sess_locking => 1 => 1
memcached.sess_prefix => memc.sess.key. => memc.sess.key.

Lots of memory:

free -m
             total       used       free     shared    buffers     cached
Mem:         15982      15712        270          0        462       9171
-/+ buffers/cache:       6078       9903
Swap:         3813          0       3813

Here is test script to reproduce (test.php):

<?php

$m = new Memcached('mc');
$m->addServer('localhost', 11211);

$d = $m->get('foo');
if(empty($d)){
    $m->set('foo', 100);
}
var_export($d);
echo $m->getResultMessage(),"\n";

Here is my GDB: https://gist.github.com/4b966fa47cd0515ddf25
Here is the core dump: https://dl.dropbox.com/u/1374786/core-php5-fpm.19325.bz2

then simply run ab -n 1000 -c 20 http://localhost/test.php

Any idea what is going on? Is this really a bug in libmemcached?

@doapp-ryanp
Copy link
Contributor Author

I just found out that when using persistent connections, you should not re-add servers.

After making the following change things work without problem:

<?php

$m = new Memcached('mc');

if (!count($m->getServerList())) {
    $m->addServer('localhost', 11211);
}

$d = $m->get('foo');
if(empty($d)){
    $m->set('foo', 100);
}
var_export($d);
echo $m->getResultMessage(),"\n";

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

No branches or pull requests

1 participant