[Catalyst] Shared database handles

Len Jaffe lenjaffe at jaffesystems.com
Mon May 8 02:08:42 CEST 2006



--- Matt S Trout <dbix-class at trout.me.uk> wrote:

> Len Jaffe wrote:
> > 
> > --- Eduardo Anuel <eanuel at gmail.com> wrote:
> > 
> > 
> >> There is an explanation to the issue there and a
> >> solution for Class
> >> DBI, but sadly in my application I use mostly
> pure
> >> DBI with the
> >> Catalyst::Model::DBI module, 
> > 
> > Make sure that you're using Apache::DBI in your
> > setup.pl.  Make sure that you don't make your DB
> > connection in setup.pl, but do connect early in
> your
> > handler. Make liberal use of connect_cached() and
> > prepare_cached().
> 
> Actually, if you're already using Apache::DBI I'd
> recommend dumping it 
> and seeing if that fixes the problem; it does all
> sorts of silly magic 
> that breaks spectacularly on edge cases.
> 
> Apache::DBI is fine if you always call DBI->connect
> yourself and don't 
> persist a $dbh anywhere. If not, it's
> almost-certain-death. Don't risk it.
> 

RIght, and since he's using "pure DBI", he's probabaly
calling connect himself.  Changes are he's calling it
in setup.pl instead of in the children. Hence my
advice to use connect_cached().

As far as I know, I've never personnaly persisted a
$dbh, and can't readily think of a reason to.  It's a
huge win to connect once and stay connected.

How else does one do persistent $dbh ?

Len.

Leonard A. Jaffe     lenjaffe at jaffesystems.com
Leonard Jaffe Computer Systems Consulting Ltd.
Columbus, OH, USA 614-404-4214 F: 530-380-7423



More information about the Catalyst mailing list