stumped - data dissapearing

Mauro Infantino plenque at gmail.com
Thu Jun 28 04:32:34 UTC 2007


Lou Kosak wrote:
> I've looked all over and can't seem to figure out why my memcache
> session data is periodically disappearing.  Here's my setup:
>
> On one server, I'm running memcached 1.2.2
>
> memcached -d -m 1024 -u memcached -l 172.17.10.158 -p 11211
>
> On another, I'm running a PHP 5 webapp with ADOdb session handling.
> I've added functionality to session read, write, and destroy, which
> looks like this:
>
> session write modifications:
>
>        if($memcache)
>        {
>            if($memcache->set(MEMCACHE_PREFIX_SESSION . "$key",
> rawurlencode($value), 0, 900)) {
>                Debug::notice('Wrote session data to memcache (' .
> MEMCACHE_PREFIX_SESSION . $key.')');
>            } else {
>                Debug::notice("Failed to write session data to memcache");
>            }
>        }
>
> session read modifications:
>
>         if($memcache)
>         {   
>             $v = $memcache->get(MEMCACHE_PREFIX_SESSION . $key);
>            
>             if($v)
>             {
>                 Debug::notice('Retrieved session data from memcache 
> (Skipped DB)');
>                
>                 $v = rawurldecode($v);
>
>                 return $v;
>             } else {
>                 Debug::notice('Memcache key does not exist: ' .
> MEMCACHE_PREFIX_SESSION . $key);
>             }
>         }
>
> session destroy modifications:
>
>         if($memcache)
>         {
>             $memcache->delete(MEMCACHE_PREFIX_SESSION . "$key");
>         }
>
>
> memcache stats:
>
>    [pid] => 14287
>    [uptime] => 105065
>    [time] => 1183003550
>    [version] => 1.2.2
>    [pointer_size] => 64
>    [rusage_user] => 25.541117
>    [rusage_system] => 75.528517
>    [curr_items] => 92466
>    [total_items] => 1896346
>    [bytes] => 69351332
>    [curr_connections] => 4
>    [total_connections] => 1875966
>    [connection_structures] => 526
>    [cmd_get] => 1963660
>    [cmd_set] => 1896346
>    [get_hits] => 1820297
>    [get_misses] => 143363
>    [evictions] => 0
>    [bytes_read] => 1564507648
>    [bytes_written] => 1644336306
>    [limit_maxbytes] => 1073741824
>    [threads] => 1
>
> What I'm finding is that while browsing the site, every 5-10 page
> loads I will see the error "Memcache key does not exist", but I never
> see "Failed to write session data to memcache".  The site is always
> able to connect to memcache (additional reporting of failed
> connections is not being triggered).  According to $memcache->stats(),
> I have plenty of free memory space and nothing is being evicted.  Does
> anybody have an idea of what might be causing my data not to be
> retrieved?
>
> Thank you very much!
>
I'm not familiar with ADOdb's session handling module, but could it be 
that it only writes session data when it changes? Then you could be 
hitting the
900 seconds timeout you're using when writing the session key to memcached.

Also, this could be obvious, but since I don't see it in your code, keep 
in mind that you should also modify the database when writing and 
destroying the session.

Regards,
Mauro.


More information about the memcached mailing list