InfiniteLoop has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks,
In my project Im using (running on Apache 1.3.31 + mod_perl), Im using Apache::Session::MySQL to manage logged in user sessions. On one of my boxes, I keep seeing the following message, when I do a "show processlist" on mysql:
| 3575 | <my user> | <my ip> | <my db> | Query | 993 | User lock + | SELECT GET_LOCK('Apache-Session-6b3b6cdcc7347f1eb72f6b44df0eec3 +f', 3600)
And I notice that some of the logged in sessions have slow response time. My questions:
  1. Is this something I should worry about ?
  2. Can I do something to solve this ?
  3. Could this be the reason for slow response time ?

Replies are listed 'Best First'.
Re: Apache::Session::MySQL strangeness
by samtregar (Abbot) on Sep 19, 2005 at 18:59 UTC
    1. Yes, you may have a bug in your session management code which is causing a deadlock in the DB. 2. If so you should make sure that your sessions are closed after every request. One way to do this is to use an Apache/mod_perl LogHandler. 3. Absolutely. I've seen incorrect usage of Apache::Session cause extreme slowdowns.

    -sam

Re: Apache::Session::MySQL strangeness
by 5mi11er (Deacon) on Sep 19, 2005 at 19:36 UTC
    Ditto Sam's response above. First off, make sure you need to be locking, and attempt to minimize the locking done. If possible (depends on engine type being used), you want to lock only those records that are being updated/written, not the whole table(s). And you don't want to lock at all if/when reading the database.

    Locking/Unlocking pieces and parts of databases is an underrespected art, read lots, tread carefully.

    -Scott