On Mon, Jun 27, 2011 at 12:53 PM, Octavian Rasnita <orasn...@gmail.com> 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):
>
> http://lists.scsys.co.uk/pipermail/dbix-class/2006-April/001153.html
>
> ""
> 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/DBI.pm'} && $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 startup.pl (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)
My::Model->connect->disconnect;
$DBI::connect_via = 'Apache::DBI::connect';

Reply via email to