6

I'm having an issue with my site. We were using Redis sessions, but after some issues with latency we've decided to switch back to MySQL sessions.

The app/etc/local.xml file used to look something like

<config>
    <global>
    [...]
        <session_save>db</session_save>
        <redis_session>
            <host>127.0.0.1</host>
            <port>6379</port>
            <password></password>
            <timeout>2.5</timeout>
            <persistent>sess-db2</persistent>
            <db>2</db>
            <compression_threshold>2048</compression_threshold>
            <compression_lib>gzip</compression_lib>
            <log_level>7</log_level>
            <max_concurrency>6</max_concurrency>
            <break_after_frontend>5</break_after_frontend>
            <break_after_adminhtml>30</break_after_adminhtml>
            <bot_lifetime>7200</bot_lifetime>
        </redis_session>
    </global>
    [...]
</config>

However, now with the Redis configuration removed it's

<config>
    <global>
    [...]
        <session_save>db</session_save>
    </global>
    [...]
</config>

The problem is that it looks like Redis sessions are still being used. For every connection a new exception is being logged.

Connection to Redis failed after 1 failures.

Unable to connect to Redis; falling back to MySQL handler

So it looks like even though the Redis configuration has been removed, it's still not told that it shouldn't be using Redis anymore, either.

Is there a way to force it back to using MySQL sessions?

2

Basically the short answer is that the version provided with Magento is old :(

In newer versions of the file Cm_RedisSession_Model_Session the first thing that gets checked in the __construct is if redis is enabled. When it is not enabled then the parent class is used, in this case Mage_Core_Model_Mysql4_Session

$this->_config = $config = Mage::getConfig()->getNode('global/redis_session');
if (!$config) {
    $this->_useRedis = FALSE;
    Mage::log('Redis configuration does not exist, falling back to MySQL handler.', Zend_Log::EMERG);
    parent::__construct();
    return;
}

I am not sure which version of Magento you are using but it appears to be an older version of redis in all Magento versions.

I would suggest that what you could do is take the newest version of https://github.com/colinmollenhour/Cm_RedisSession and install it on your Magento system.

Though on a side note even though it errors the fallback to mysql still appears to work, it just fills up your exception log file. So the only real change is from filling up your exception log you now fill up your system log.

If you really have an issue with the logs being filled up then you could simply disable the extension so the rewrite of Mage_Core_Model_Mysql4_Session never happens, but remember to enable it again if you change your mind and want to use redis again :)

| improve this answer | |
  • 1
    I guess updating it will prevent the latency of an attempted redis connection, which is still good. Really what needs to happen is to disable the module in app/etc/modules/Cm_RedisSession.xml. Just removing the config in app/etc/local.xml isn't enough. – Steve Robbins Jun 26 '14 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.