perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fred Moyer <>
Subject Apache::DBI and DBIx::Class [was Re: How do you use mod_perl for your web application?]
Date Mon, 27 Jun 2011 20:13:51 GMT
On Mon, Jun 27, 2011 at 12:53 PM, Octavian Rasnita <> wrote:
> Here is a comment that might be helpful, because it also explains why DBIx::Class can
work with Apache::DBI (and why it is not needed):
> ""
> DBIx::Class already manages its connections for you, and therefore it
> cannot benefit from Apache::DBI under any scenario.  It makes one
> connection per-process, and keeps that connection persistent,
> reconnecting only if the connection appears to have died, or if you
> fork/thread over to another process/thread-id.  The only Apache::DBI
> issue in DBIx::Class is that Apache::DBI will actually thwart
> DBIx::Class's connection management code, and cause it to use the same
> (and invalid) connection in a new process, in cases such as (as
> mentioned above) if you make a DBI connection before forking in a
> prefork mod_perl server.
> To work around this, DBIx::Class has specific code in it to work
> around Apache::DBI, nullifying the effects of Apache::DBI on
> DBIx::Class.  Essentially, loading Apache::DBI should change nothing
> and be rather pointless under DBIx::Class.

Wow, that's obnoxious:

1237   if ($INC{'Apache/'} && $ENV{MOD_PERL}) {
1238     $old_connect_via = $DBI::connect_via;
1239     $DBI::connect_via = 'connect';
1240   }

And it is also apparently not working as they expected:

[Mon Jun 27 13:05:17 2011] [notice] Apache/2.2.17 (Unix)
mod_apreq2-20090110/2.8.0 mod_perl/2.0.5 Perl/v5.12.3 configured --
resuming normal operations
8879 Apache::DBI             new connect to 'dbname='...

In my (My::Model is DBIx::Class based):

$Apache::DBI::DEBUG = 2;
my $db_connect_params = My::Model->connect_params;
Apache::DBI->connect_on_init( @{$db_connect_params} );
Apache::DBI->setPingTimeOut( $db_connect_params->[0], 5 );

# delete this line and I will beat you with a stick (note to self)
$DBI::connect_via = 'Apache::DBI::connect';

View raw message