perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Perrin Harkins <per...@elem.com>
Subject Re: Apache::DBI and DBIx::Class [was Re: How do you use mod_perl for your web application?]
Date Tue, 28 Jun 2011 00:23:45 GMT
Please calm down, folks.

Apache::DBI is a module that was designed to help with porting legacy
CGI applications to mod_perl.  It's a valid criticism to say that the
action-at-a-distance parts of it are undesirable in new mod_perl
applications.  Personally, I have used mostly custom caching code
instead for years.

Over time, Apache::DBI picked up some other features which are useful
in mod_perl.  If you're using something else, you should make sure you
have these or know why you don't need them.

- Startup safety.  This prevents sharing of connections opened in the
parent process during startup.  Apache::DBI does this by not caching
connections during startup.  DBIx::Class does this by making a new
connection if you fork or start a new thread.  Note the stuff about
InactiveDestroy in the DBI docs if you use DBIx::Class or
DBIx::Connector.

- Automatic rollback.  Apache::DBI issues a rollback at the end of
every request where the DBI connection was not opened in AutoCommit
mode.  This is to prevent a die() during a transaction from leaving
your database in a bad state.  If you use subroutine blocks wrapped in
eval (e.g. the transaction stuff in DBIx::Connector), this should not
be necessary, but make sure you ALWAYS do it that way if you're
counting on that to protect you.

I agree that trashing Apache::DBI is not very useful, but you should
also know what Apache::DBI was meant for and what it's limitations
are.

- Perrin

Mime
View raw message