ZF-11544: Memcache seems to be offline


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);


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:

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.

@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.

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