ZF-11544: Memcache seems to be offline

Issue Type: Bug Created: 2011-07-08T17:36:32.000+0000 Last Updated: 2012-05-31T14:07:31.000+0000 Status: Closed Fix version(s): Reporter: Nicolas Lescure (nlescure) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Cache

  • Zend_cache

Related issues: Attachments:


Sometimes, with memcache activated, it seems the memcache server is down.

An exception is thrown each times the problem occures "Can\'t get filling percentage."

The problem is in Zend/Cache/BackendMemcached.php The function php function getExtendedStats() is buggy and sometimes return false, even if memcache servers are online. The bug is declared here :

If you can have only one memcache server, you can use this patch : //$mems = $this->_memcache->getExtendedStats(); $memsStats = $this->_memcache->getStats(); $mems = array($memsStats);


Posted by Iwan (istaveren) on 2011-09-16T06:23:25.000+0000

This problem can be reproduced by using the TwoLevel backend and memcached as the fast one. Then when there is no memcached server available you get the following error: {quote} Exception 'Zend_Cache_Exception' with message 'Can't get filling percentage' {quote}

The problem and fixed it like this:

<pre class="highlight">
Index: 1.11.4/Cache/Backend/Memcached.php
--- 1.11.4/Cache/Backend/Memcached.php  (revision 117)
+++ 1.11.4/Cache/Backend/Memcached.php  (revision 118)
@@ -399,8 +399,12 @@
             $memUsed += $eachUsed;
-        if ($memSize === null || $memUsed === null) {
-            Zend_Cache::throwException('Can\'t get filling percentage');
+        if ($memSize === null || $memUsed === null) 
+        {
+          $memSize = 1;
+          $memUsed = 1;
+          $this->_log('Can\'t get filling percentage', Zend_Log::INFO);
         return ((int) (100. * ($memUsed / $memSize)));

This will return a 100% filling percentage if the memcached server is not available.

Posted by Nicolas Lescure (nlescure) on 2011-09-16T07:01:31.000+0000

@Iwan As you said, your patch returns 100% if memcache does not respond, even if memcache is not down. With your solution, you think the disk is full, and your application will generate errors. You really have to know when there is a problem or not.

Posted by Gonzalo Sainz-Trapaga (gomox) on 2012-05-31T14:07:31.000+0000

Workaround for this is just not restarting Memcached. Wipe your cache using the API functions.

Have you found an issue?

See the Overview section for more details.


© 2006-2022 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.