[Catalyst] Re: [Catalyst-dev] Bug in Catalyst::Model::DBI .15

Alex Pavlovic alex at taskforce-1.com
Sat May 5 06:12:27 GMT 2007


Hi,

On Friday 04 May 2007 19:01, Evan Carroll wrote:
> M::DBI has a pretty sizable bug in as is such that it will establish a
> new DBI handle on every incoming connection. 

In what environment CGI, FCGI, mod_perl ? You did not mention.

> This is a problem for 
> speed, and transactions as it makes it much more difficult to share
> $dbh across other models, 

If you want to share $dbh across multiple models then take a look at:

http://search.cpan.org/author/ALEXP/Catalyst-Model-Proxy-0.03/lib/Catalyst/Model/Proxy.pm

It has already been done.

> or to wrap them. I'm very surprised this 
> went for such a long time undiscovered. 

What went on undiscovered ? I still dont understand what you are trying to 
accomplish. You can't share dbh across threads or multiple processes( because 
each connection results in distinct namespace ). DBIx::Class::Storage does 
the same thing, look at:

http://search.cpan.org/~blblack/DBIx-Class-0.07006/lib/DBIx/Class/Storage/DBI.pm

<code>
elsif($self->_conn_pid != $$) {
          $self->_dbh->{InactiveDestroy} = 1;
          return $self->_dbh(undef);
}
</code>

> This one line caused a lot of 
> grief.

What kind of grief ?

>
> Thanks goes to >nothingmuch for all his help in first blaming the
> problem totally on my style, and then later totally on M::DBI.

I assume this was on irc. Next time please contact me before posting anything, 
it will save you some time and "grief". Not sure what your patch does here, 
maybe you can clarify.

>
> root at x60s:/usr/local/share/perl/5.8.8/Catalyst/Model# diff DBI.pm
> DBI_FIX.pm 59a60,62
>
> >       $self->_dbh( $self->connect );
>
> 72c75
> <                       } elsif ( $self->_pid != $$ ) {
> ---
>
> >       } elsif ( $self->_pid != $$ ) {
>
> --
> Evan Carroll
> System Lord of the Internets
> me at evancarroll.com
> 832-445-8877

-- 
Alex Pavlovic - CTO
TF-1 Inc. ( Custom development, consultancy and training )
http://taskforce-1.com



More information about the Catalyst mailing list