Skip to content
This repository has been archived by the owner on Jun 10, 2019. It is now read-only.

Redis sessions #13

Closed
icurdinj opened this issue Jan 4, 2016 · 8 comments
Closed

Redis sessions #13

icurdinj opened this issue Jan 4, 2016 · 8 comments

Comments

@icurdinj
Copy link
Contributor

icurdinj commented Jan 4, 2016

Just so it's documented here: Redis sessions probably crash.
We now have a pretty good idea how to fix this (the same as db sessions), and will get around to it as soon as we have a Redis environment to test that.
Meanwhile, if someone else already did this, pull requests are always welcome.

@icurdinj
Copy link
Contributor Author

Redis works with PHP 7.
Block cache in Redis works as is.
Cm_RedisSession crashes, but there is a beautiful workaround: keep Cm_RedisSession disabled, and add these two lines to local.xml:

<session_save><![CDATA[redis]]></session_save>
<session_save_path><![CDATA[tcp://127.0.0.1:6379?database=0]]></session_save_path>

Why it works? Because PHP has native session handler in Redis. (You need the php-redis module, but you would want it anyway.)

@ivanweiler
Copy link
Contributor

Maybe a bit early to close.

It seems native phpredis doesn't support session locking which could cause serious issues in Magento, check phpredis/phpredis#37

I can't find any log mentioning that locking is implemented in php7-redis version :(

Cm_RedisSession implements locking mechanism and it also has fallback to db sessions if Redis is unavailable, or socket fallback if phpredis is unavailable, so we need to fix it.

Btw. it seems Cm_RedisSession + sockets (without native phpredis) is working on windows/php7, I am able to login. And I tested one ubuntu/php7/phpredis setup where it worked without problems, but it was earlier build of php7 and php7-redis, not the last one.

I think we should wait for new official phpredis release for php7, there is working branch, but not release.

@icurdinj
Copy link
Contributor Author

Good find! Reopening issue. So, to conclude, we need someone to fix phpredis :-)
Options until then:

  1. Use Cm_RedisSession on a server with Redis, but without phpredis module.
  2. Use Redis only for block cache, and files or db session storage.
  3. Fix Cm_RedisSession to not crash on a system with phpredis. (If someone does, please make a pull request.)

@icurdinj icurdinj reopened this Jan 14, 2016
@rjocoleman
Copy link

@icurdinj do you have steps to reproduce for Cm_RedisSession and phpredis crashing please?

I'm happy to dig in to resolve this wherever it's best mitigated, but I'm using PHP 7.0.2 and phpredis's master branch and I'm not having any issues.

@icurdinj
Copy link
Contributor Author

Ubuntu 15.10, using https://launchpad.net/~ondrej/+archive/ubuntu/php?field.series_filter=wily for PHP 7.0.2 and phpredis 2.2.7. So, the only difference I see is that you are you using phpredis master branch, instead of latest release.
It would be great if this is fixed in phpredis master. Though, it would be greater if someone fixed phpredis native sessions, so we could replace the whole Cm_RedisSession extension with 2 lines of XML...

@rjocoleman
Copy link

I misspoke, I'm using the php7 branch of phpredis.

Version 2.2.7 doesn't have PHP 7 support, it's supported in the php7 branch and this isn't available via PECL yet - per phpredis/phpredis#692

Before looking into the separate locking issue maybe this is the cause of the crash?

@arosenhagen
Copy link

I can confirm that as of PHP 7.0.2 Cm_RedisSession is working as expected (for me I tested with phpredis on php7 branch) see also colinmollenhour/Cm_RedisSession#70 (comment)

@icurdinj
Copy link
Contributor Author

Time to close this issue. The only problem encountered, with phpredis module, seems to be fixed in their master branch, and even if you encounter that, there are a few viable workarounds. No need to code anything in this extension.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants