0

I have two web servers with a Magento instance on both. Each shares the same httpd.conf, php.ini and my.cnf, along with local.xml and config.xml magento configuration files.

I have another server that stores both the shared DB and shared Memcache instance. Both Magento web servers are able to successfully hit the DB instance, but only ONE of the Magento instances is working properly with memcache.

When I make a request to the magento instance that is NOT working w/memcache, I get the following error:

There has been an error processing your request

Warning: session_start() [function.session-start]: open(tcp://INTERNAL_IP_OF_MEMCACHE_SERVER:11211?persistent=1&weight=2&timeout=10&retry_interval=10/sess_9bmgdui99pr39fagpnoa53prl5, O_RDWR) failed: No such file or directory (2)  in /var/www/html/production-host/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php on line 113

Trace:
#0 [internal function]: mageCoreErrorHandler(2, 'session_start()...', '/var/www/html/p...', 113, Array)
#1 /var/www/html/production-host/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php(113): session_start()
#2 /var/www/html/production-host/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php(153): Mage_Core_Model_Session_Abstract_Varien->start('frontend')
#3 /var/www/html/production-host/app/code/core/Mage/Core/Model/Session/Abstract.php(84): Mage_Core_Model_Session_Abstract_Varien->init('core', 'frontend')
#4 /var/www/html/production-host/app/code/core/Mage/Core/Model/Session.php(39): Mage_Core_Model_Session_Abstract->init('core', 'frontend')
#5 /var/www/html/production-host/app/code/core/Mage/Core/Model/Config.php(1206): Mage_Core_Model_Session->__construct(Array)
#6 /var/www/html/production-host/app/Mage.php(432): Mage_Core_Model_Config->getModelInstance('core/session', Array)
#7 /var/www/html/production-host/app/Mage.php(446): Mage::getModel('core/session', Array)
#8 /var/www/html/production-host/app/code/core/Mage/Core/Controller/Varien/Action.php(483): Mage::getSingleton('core/session', Array)
#9 /var/www/html/production-host/app/code/core/Mage/Core/Controller/Front/Action.php(59): Mage_Core_Controller_Varien_Action->preDispatch()
#10 /var/www/html/production-host/app/code/core/Mage/Core/Controller/Varien/Action.php(407): Mage_Core_Controller_Front_Action->preDispatch()
#11 /var/www/html/production-host/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#12 /var/www/html/production-host/app/code/core/Mage/Core/Controller/Varien/Front.php(177): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#13 /var/www/html/production-host/app/code/core/Mage/Core/Model/App.php(304): Mage_Core_Controller_Varien_Front->dispatch()
#14 /var/www/html/production-host/app/Mage.php(596): Mage_Core_Model_App->run(Array)
#15 /var/www/html/production-host/index.php(83): Mage::run('', 'store')
#16 {main}

I've successfully telneted from the this above machine to the memcache server onto port 11211 and I can connect to the memcache instance fine. I've also made sure each system has the correct extensions installed via php -m and diff'd the output of "php_info" (they are identical).

I realize the session_start() is having an issue connecting to the memcache instance, but I don't understand why? TIA!

EDIT/UPDATE:

This is Magento enterprise version: 1.5 I believe (checking now) and the local.xml is:

> <config>   <global>
>     <install>
>       <date><![CDATA[REDACTED]]></date>
>     </install>
>     <crypt>
>       <key><![CDATA[REDACTED]]></key>
>     </crypt>
>     <disable_local_modules>false</disable_local_modules>
>     <resources>
>       <db>
>         <table_prefix></table_prefix>
>       </db>
>       <default_setup>
>         <connection>
>           <host><![CDATA[REDACTED]]></host>
>           <username><![CDATA[REDACTED]]></username>
>           <password><![CDATA[REDACTED]]></password>
>           <dbname><![CDATA[REDACTED]]></dbname>
>           <active>1</active>
>         </connection>
>       </default_setup>
>     </resources>
>     <session_save><![CDATA[memcached]]></session_save>
>    
> <session_save_path><![CDATA[tcp://REDACTED:11211?persistent=1&weight=2&timeout=10&retry_interval=10]]></session_save_path>
>     <session_cache_limiter></session_cache_limiter> <cache>
> <slow_backend>database</slow_backend>
> <fast_backend>Memcached</fast_backend> <fast_backend_options>  
> <servers>
>     <server>
>       <host>REDACTED</host>
>       <port>11211</port>
>       <persistent>1</persistent>
>     </server>   </servers> </fast_backend_options>
> 
> <backend>memcached</backend> <memcached>   <servers>
>     <server>
>       <host>REDACTED</host>
>       <port>11211</port>
>       <persistent>1</persistent>
>     </server>   </servers>  <compression><![CDATA[0]]></compression> 
> <cache_dir><![CDATA[]]></cache_dir>
> <hashed_directory_level><![CDATA[]]></hashed_directory_level>
> <hashed_directory_umask><![CDATA[]]></hashed_directory_umask>
> <file_name_prefix><![CDATA[]]></file_name_prefix> </memcached>
> </cache>   </global>   <admin>
>     <routers>
>       <adminhtml>
>         <args>
>           <frontName><![CDATA[REDACTED]]></frontName>
>         </args>
>       </adminhtml>
>     </routers>   </admin> </config>

And these are the values in the file right before it calls "session_start":

[x] method = memcached

[x] savepath = tcp://REDACTED:11211?persistent=1&weight=2&timeout=10&retry_interval=10

UPDATE:

I've also created a test script that contains:

$fp = fsockopen('REDACTED', '11211');
if (!$fp)
{

And I run it as apache:

sudo -u apache php test.php

and it is able to connect fine.

mr-sk
  • 101
  • 1
  • 3
  • What does your local.xml setup look like on each web head? (minus credentials obviously), also what version of Magento? –  Aug 22 '11 at 18:48
  • I guess you have to make your php test file also using magento/zend functionality to get closer – Anton S Aug 22 '11 at 20:20

2 Answers2

1

I recommend considering switching to Redis for both your session storage and your cache storage. Reasons:

  • Memcached is not a good fit for Magento caching due to the heavy dependence on cache tags. Having a two-level backend is needlessly complicated and slow, my Redis backend supports tagging without TwoLevels.
  • Using non-persistent cache storage means if you have to reboot you will have a cold cache.
  • Using non-persistent session storage means if you have to reboot all of your users lose their sessions.
  • Redis is bloody fast.

Redis can be configured with a max memory limit. You could run two instances to control the size of the cache and the session storage independently if needed and it can be configured to use LRU for eviction when it is full.

The phpredis extension supports a native session storage plugin but I have not tested it with Magento.

ColinM
  • 701
  • 8
  • 19
1

You should start debugging the issue by excluding Magento from the possible culprits. Ie. do regular PHP memcache sessions work?

Try a test.php with:

<?php
ini_set("session.save_handler","memcache");
ini_set("session.save_path","127.0.0.1:11211");
session_start();
print "Session started..\n<br />\n";
?>

If this works, then look into the code (app/code/core/Mage/Core/Model/Session/Abstract/Varien.php) to see whether Magento possibly overwrites the save_path.

Also, are you absolutely sure your session handler is memcached? Doublecheck with the output from phpinfo() (under: registered session handlers).

Willem
  • 2,872
  • 4
  • 28
  • 35