Cm_RedisSession icon indicating copy to clipboard operation
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

Open ciderpunx opened this issue 8 years ago • 8 comments

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

ciderpunx avatar Apr 13 '17 10:04 ciderpunx

Ahh actually it looks like another user just reported the issue with the explanation on colinmollenhour/credis#79..

colinmollenhour avatar Apr 13 '17 14:04 colinmollenhour

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.

colinmollenhour avatar Apr 13 '17 14:04 colinmollenhour

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             }

ciderpunx avatar Apr 19 '17 14:04 ciderpunx

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

colinmollenhour avatar Apr 19 '17 14:04 colinmollenhour

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;

ciderpunx avatar Apr 19 '17 14:04 ciderpunx

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 avatar Apr 19 '17 16:04 colinmollenhour

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

jefweb avatar Apr 20 '17 15:04 jefweb

Thank you for the solution !

Amadeco avatar Feb 28 '18 13:02 Amadeco