Third party Memcache Based Session Fails If Any ("Redundant") Server Is Down

digitalpoint

Well-known member
Memcache has built in fault tolerance via the PHP extension's addServer() connection pool (which Zend/XF uses just fine).

If any one memcache server is down, the XF's session causes a fatal error even though nothing is actually wrong on the backend end (again... the PHP extension handles failover of the memcache cluster internally).

It looks like the Zend_Session class already has the ability to not fail on a startup exception (more specifically in this case I believe it's a PHP notice that's being treated as a fatal exception). Info on the same issue here: http://framework.zend.com/issues/browse/ZF-6848

It looks like the two session start lines in XenForo_Session could be changed to this (since the start() method already allows passing in the throw_startup_exceptions option):

PHP:
$session->start(array('throw_startup_exceptions' => E_ALL ^ E_NOTICE));

Long story short is if one memcache server goes down, the failover is already handled in PHP, but XF will end up with fatal error for any page the way it is now.
 
The workaround here is to specify a failure_callback with an empty function in the configuration of the servers. Otherwise, the memcache library itself issues a notice which ends up getting caught by our error handling.

I'd recommend the failure_callback setting.
 
Adding
Code:
'failure_callback' => ''
to the memcache config in config.php
results in an error.

Is there a better way to add failure_callback correctly?
 
Top Bottom