I have been playing around with Apache::Session and had it working with MySQL -- then decided to switch to Memcached

It seemed to be working but would randomly fail during my testing and the session ID would start rotating around -- if I reloaded the page over and over it would keep the same ID, then randomly change it and I could not figure out why. After some testing I found the following:

If I telnet to the memcached port and type "stats" to see the statistics, I see that curr_connections is high and stays that way -- I believe this is due to mod_perl keeping the connections open for each process. I removed the "Apache::DBI" library option to make sure that was not causing persistant connections, but the curr_connections continued to stay high after many reloads of a webpage.

It seems the failures occur after i kill and restart the memcached daemon, but not restart Apache. I am guessing that the connections to memcached are staying persistant with each apache child, and then when i restart memcached they become invalid and fail, causing the session ID's to rotate.

Does anyone have a solution to this?  I was originally doing this:

autohandler
===
<%init>
### this was a library routine i had in a "use" that tied to a "my" hash and returned \%session
my $session = getSession ();
</%init>
=====


Next i tried adding to autohandler:
=====
<%cleanup>
untie %$session
undef $session
</%cleanup>
=======

That did not stop the curr_connection problem. I also tried putting the getSession code directly into %init, and also used local * as in the mason book.

I am now using this line in Apache/http.conf

PerlSetVar MasonAllowGlobals %session

to make it global, merely to make it easier to pass this data around (as suggested in the mason book)... it seems to be working but i still get that failure if memcached is restarted without restarting apache.

The mason book mentions something about local * and how it is necessary for closing the connection when done, but I have had no luck. Any thoughts? A working example would be helpful.

Oh one other question -- anyone know how to detect a failure to connect to memcached?... it seems that if memcached is not up, that it just returns the error that the object does not exist, rather than a connection failure error?

Thanks
-John




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to