Cm_RedisSession
Cm_RedisSession copied to clipboard
Upgrade of php5 from 5.4.45-0+deb7u7 to 5.4.45-0+deb7u8 on Debian causes redis connection error
We recently upgraded php5 on our Debian Wheezy server to a more recent version. After the upgrade Magento started crashing with these errors:
a:5:{i:0;s:126:"Connection to Redis 127.0.0.1:6379 failed after 2 failures.Last Error : (0) Failed to parse address "127.0.0.1:6379/cache-fpc"";i:1;s:3217:"#0 /path/to/magento/.modman/Cm_RedisSession/cr
edis/Client.php(448): Credis_Client->connect()
Nothing else has changed.
Currently I have php held at the older version which resolves the problem.
Is there something I need to do to make the newer php play nice (I'd like to start moving towards using stretch this year, so using later php versions is important for me).
Ahh actually it looks like another user just reported the issue with the explanation on colinmollenhour/credis#79..
Quick fix is to remove your persistent connection identifier from the connection string in your config. If you use the same Redis server for cache and sessions and have persistent connections enabled for both with different ids this could be a problem.. For now I think you would need to disable persistent connections entirely to avoid the same connection being used for cache and sessions, although I haven't tested this to confirm.
Thanks for your prompt response and many apologies for my tardy reply. Easter and all that.
As it happened, changing my config in local.xml to have empty strings for persistent did not resolve the issue.
I did however manage to fix it by commenting line 430 which adds the identifier in Cm_RedisSession/credis/Client.php:
428 if ($this->persistent && $this->port !== NULL) {
429 // Persistent connections to UNIX sockets are not supported
430 // $remote_socket .= '/'.$this->persistent;
433 $flags = $flags | STREAM_CLIENT_PERSISTENT;
434 }
Are you using the latest version? It looks like in the latest version the persistent option is cast to a string so a patch should not be necessary. If it was not cast in an older version then it could be evaluating to a truthy value (xml node instance).
I think so but don't know where to look for the version number!
$ modman update Cm_RedisSession
Already up-to-date.
Submodule 'php-redis-session-abstract' () registered for path 'code/lib'
Submodule 'credis' () registered for path 'credis'
Update of Cm_RedisSession complete.
I can see that persistent gets cast on line 303, so it points to being the right version:
303 $this->persistent = (string) $persistent;
Ok, I didn't know if you had the bundled version or the github module. If you just cloned it off of github with modman then you should be using the latest by default.
Have you tried commenting out the <persistent> node in the config instead of specifying an empty string? It really shouldn't make a difference but I have not had the opportunity to look into it further. Please post the <redis_session> node of your config if you are still having issues.
@colinmollenhour I have tested this briefly and can confirm that commenting out the <persistent> node allowed a successful connection. If using Redis for caching will have to do this on the <cache> and <full_page_cache> nodes as well.
Thank you for the solution !