php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59602 getExtendedStats fails on the host intermittently after restarting memcache
Submitted: 2011-02-02 17:36 UTC Modified: 2013-02-18 00:35 UTC
Votes:7
Avg. Score:4.9 ± 0.3
Reproduced:7 of 7 (100.0%)
Same Version:2 (28.6%)
Same OS:2 (28.6%)
From: tilman78 at gmx dot de Assigned: remi (profile)
Status: No Feedback Package: memcache (PECL)
PHP Version: 5.3.5 OS: Ubuntu Lucid 10.04 LTS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tilman78 at gmx dot de
New email:
PHP Version: OS:

 

 [2011-02-02 17:36 UTC] tilman78 at gmx dot de
Description:
------------
After restarting memcached getExtendedStats() as well as getStats() returns false on the server intermittently for a while. It seems once memcache is in use, the stats are coming back reliably.

Switching back to the latest stable 2.2.6 the issue does not appear.

This was tested with memcached version 1.4.2. It was only tested against a single localhost server.

How to reproduce:
1. Create a simple test script, see below.

2. Restart memcached:
sudo /etc/init.d/memcached restart

3. Hit the test script several times right after restarting memcached. Sometimes stats are returned, sometimes not.



Reproduce code:
---------------
$memcache_obj = new Memcache;
$memcache_obj->addServer('127.0.0.1', 11211);
var_dump($memcache_obj);

$stats = $memcache_obj->getExtendedStats();
var_dump($stats);

$stats = $memcache_obj->getStats();
var_dump($stats);


Expected result:
----------------
If memcached is running, the stats should always be returned.

Actual result:
--------------
Stats are not returned sometimes.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-16 08:33 UTC] snoll at linux dot com
Greetings,

I was experiencing a similar issue on both Ubuntu 10.10 and 
CentOS 6.  An interesting trend I noticed was that the 
intermittent issue would go away - seemingly working itself 
out - about a minute after the memcached restart.  

I can now avoid the issue by doing the following:

Run:
---------------------------------
sudo /etc/init.d/memcached stop

Then run:
---------------------------------
sudo netstat -anp | grep 11211

You will probably get a response similar to the following:
tcp        0      0 127.0.0.1:11211             
127.0.0.1:54227             TIME_WAIT   -                   
tcp        0      0 127.0.0.1:11211             
127.0.0.1:54224             TIME_WAIT   -                   
tcp        0      0 127.0.0.1:11211             
127.0.0.1:54226             TIME_WAIT   -                   
tcp        0      0 127.0.0.1:11211             
127.0.0.1:54225             TIME_WAIT   -                   
tcp        0      0 127.0.0.1:11211             
127.0.0.1:54223             TIME_WAIT   - 

Once the tcp TIME_WAITs expire and the netstat command 
displays no results (it seems to take approximately 30 
seconds), then run:
--------------------------------
sudo /etc/init.d/memcached start

When I wait for the TIME_WAITs to expire memcached seems to 
work as expected and the intermittent issue no longer 
occurs. 

I'm curious to know if waiting for the TIME_WAITs to expire 
resolves your issue as well.

I hope this helps.

Cheers.
 [2011-10-04 05:30 UTC] nlescure at ayaline dot com
Hi,

I have the same problem on Magento (Zend Framework) when it 
uses memcache.
I declared the bug here : 
http://framework.zend.com/issues/browse/ZF-11544?
page=com.atlassian.jira.plugin.system.issuetabpanels:comment
-tabpanel&focusedCommentId=48451

The function getExtendedStats() is buggy and sometimes 
return false, even if memcache servers are online. 

Please give us a feedback and if you can reproduce this bug.

The bug occures with php 5.3.8 on centos.
 [2012-10-31 12:22 UTC] remi@php.net
I can reproduce the segfault:

(gdb) bt
#0  _zend_hash_add_or_update (ht=0x7fffcfbe4118, arKey=arKey@entry=0x7fffcfbe41d0 "pid", nKeyLength=nKeyLength@entry=4, pData=pData@entry=
    0x7fffffffa2c8, nDataSize=nDataSize@entry=8, pDest=pDest@entry=0x0, flag=flag@entry=1) at /usr/src/debug/php-5.4.8/Zend/zend_hash.c:220
#1  0x00000000005c745c in zend_symtable_update (pDest=0x0, pData=0x7fffffffa2c8, nKeyLength=4, arKey=0x7fffcfbe41d0 "pid", ht=<optimized out>, 
    nDataSize=<optimized out>) at /usr/src/debug/php-5.4.8/Zend/zend_hash.h:351
#2  add_assoc_stringl_ex (arg=arg@entry=0x7fffcfbe41a0, key=key@entry=0x7fffcfbe41d0 "pid", key_len=key_len@entry=4, str=str@entry=
    0x14d6411 "27264\r\n", length=length@entry=5, duplicate=duplicate@entry=1) at /usr/src/debug/php-5.4.8/Zend/zend_API.c:1234
#3  0x00007fffe4d38adb in mmc_stats_parse_stat (start=start@entry=0x14d640d "pid 27264\r\n", end=end@entry=0x14d6415 "4\r\n", result=result@entry=
    0x7fffcfbe41a0) at /usr/src/debug/php-pecl-memcache-3.0.7/memcache-3.0.7/memcache.c:926
#4  0x00007fffe4d38eaf in mmc_stats_handler (param=0x7fffcfbe41a0, message_len=14, message=0x14d6408 "STAT pid 27264\r\n", mmc=<optimized out>, 
    request=<optimized out>, response=<optimized out>) at /usr/src/debug/php-pecl-memcache-3.0.7/memcache-3.0.7/memcache.c:1705
#5  mmc_stats_handler (mmc=<optimized out>, request=<optimized out>, response=<optimized out>, message=0x14d6408 "STAT pid 27264\r\n", 
    message_len=<optimized out>, param=0x7fffcfbe41a0) at /usr/src/debug/php-pecl-memcache-3.0.7/memcache-3.0.7/memcache.c:1689
#6  0x00007fffe4d3f541 in mmc_request_parse_response (mmc=0x14d63b0, request=0x7ffff7fbf480)
    at /usr/src/debug/php-pecl-memcache-3.0.7/memcache-3.0.7/memcache_ascii_protocol.c:109
#7  0x00007fffe4d3cf8e in mmc_pool_select (pool=pool@entry=0x7ffff7fbe998)
    at /usr/src/debug/php-pecl-memcache-3.0.7/memcache-3.0.7/memcache_pool.c:1588
#8  0x00007fffe4d3d9e8 in mmc_pool_run (pool=0x7ffff7fbe998) at /usr/src/debug/php-pecl-memcache-3.0.7/memcache-3.0.7/memcache_pool.c:1674
#9  0x00007fffe4d37a12 in zif_memcache_get_extended_stats (ht=<optimized out>, return_value=0x7ffff7fbeec8, return_value_ptr=<optimized out>, 
    this_ptr=<optimized out>, return_value_used=<optimized out>) at /usr/src/debug/php-pecl-memcache-3.0.7/memcache-3.0.7/memcache.c:1843
#10 0x00007ffff17e0b4d in xdebug_execute_internal () from /usr/lib64/php/modules/xdebug.so
#11 0x000000000066a06e in zend_do_fcall_common_helper_SPEC (execute_data=<optimized out>) at /usr/src/debug/php-5.4.8/Zend/zend_vm_execute.h:644
#12 0x0000000000623ec7 in execute (op_array=0x7ffff7fbda60) at /usr/src/debug/php-5.4.8/Zend/zend_vm_execute.h:410
#13 0x00007ffff17e0fd2 in xdebug_execute () from /usr/lib64/php/modules/xdebug.so
#14 0x00000000005c4c4c in zend_execute_scripts (type=type@entry=8, retval=retval@entry=0x0, file_count=file_count@entry=3)
    at /usr/src/debug/php-5.4.8/Zend/zend.c:1309
#15 0x000000000056468d in php_execute_script (primary_file=primary_file@entry=0x7fffffffcbb0) at /usr/src/debug/php-5.4.8/main/main.c:2482
#16 0x000000000066c8c6 in do_cli (argc=2, argv=0x7fffffffe048) at /usr/src/debug/php-5.4.8/sapi/cli/php_cli.c:988
#17 0x0000000000425b0a in main (argc=2, argv=0x7fffffffe048) at /usr/src/debug/php-5.4.8/sapi/cli/php_cli.c:1364


I think I have a fix for this
 [2012-10-31 12:26 UTC] remi@php.net
Automatic comment from SVN on behalf of remi
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=328202
Log: Related bug #59602 getExtendedStats
 [2012-11-04 16:27 UTC] hradtke@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: remi
 [2012-11-04 16:28 UTC] hradtke@php.net
-Status: Assigned +Status: Feedback
 [2012-11-04 16:28 UTC] hradtke@php.net
Remi committed a fix for this bug. Please checkout master and verify the bug is 
fixed.
 [2013-02-18 00:35 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 12:01:27 2024 UTC