You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Perrin Harkins <pe...@elem.com> on 2005/01/04 00:40:16 UTC

Re: apache:session and mod perl

On Fri, 2004-12-31 at 09:51 -0800, Chris Ochs wrote:
> A deadlock happens when you have an updater that acquires a write
> lock, but it's waiting for the first updater that is also in a SELECT
> FOR UPDATE but has not yet acquired a write lock.

There is no such thing as a write lock for the Postgres subclass.  It
grabs a lock when you materialize the session and doesn't give it up or
try to get another one until the session object is DESTROYed.

> The first updater
> can't finish because it can't acquire a write lock that the second
> updater has already obtained, and the second updater can't update
> until the first one finishes, which it can't.

Only one can get a lock on a particular session at once, which is by
design.  There is no deadlock though, since only a single lock is
involved here.

> A workable hack would probably be to have Apache::Session::Lock::File
> always set Transaction to 1 if the backend store was postgres.

You *really* should not need Apache::Session::Lock::File with Postgres
if you are not doing anything crazy with Postgres isolation levels and
transactions.  I regret bringing it up now.  You need to back up and
figure out what's going wrong with your Postgres stuff.  Are you doing
commits on this same database handle that would cause the lock to be
released too early?

Going back to an earlier mail:
> If it is a scoping issue it's probably in one of the Apache::Session
> modules

I think someone would have found that by now.

> The session is kept in a
> global request object I use for all variables that need to be passed
> around.  In the cleanup handler I untie the session and undefined the
> request object, and log it all with log4perl.

That should work, but no other request will be able to read the same
session until your cleanup handler has run.

> I just figured that File locking wasn't supported or tested
> with the Postgresql backend store

It's not.

> > I put some loggin into apache::session::lock::file, and then switched
> > between using apache::session::file and apache::session::flex with
> > postgres and Lock set to File.

Can you try it with just Postgres?

- Perrin



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html