You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Joshua Hoblitt <jh...@ifa.hawaii.edu> on 2004/12/15 04:12:52 UTC
Apache::DBI 0.94 - connect_on_init broken?
Hi Folks,
This is my first serious attempt at working with mod_perl so please excuse me
if this e-mail is a little naive.
I have a SOAP::Transport::HTTP::Apache application that makes fairly heavy use
of DBI. I would like to use Apache::DBI so I don't have to write my own logic
for keep alives and reconnecting broken database handles. Unfortunately, the
connect_on_init method does not seem to work for me.
When I place this snippet in my Apache configuration my database (MySQL)
reports that no database threads have been spawned.
--
PerlModule DBI
PerlModule Apache::DBI
.
.
<perl>
Apache::DBI->connect_on_init(
"DBI:mysql:database=foo:host=localhost",
"foo",
"foo",
);
</perl>
--
When I replace that with:
--
PerlModule My::Foo
.
.
<perl>
Apache->push_handlers(PerlChildInitHandler => sub {
My::Foo->setup(
"DBI:mysql:database=foo:host=localhost",
"foo",
"foo",
);
}
);
</perl>
--
Where ->setup is creating a database handle and storing it in a package
variable. The database reports 64 threads (the number of Apache children at
startup) active on the database. This has left me completely puzzled as
Apache::DBI is also installing a PerChildInitHandler.
I'm running this with Perl 5.8.5 on Apache 1.3.33/mod_perl 1.29.
Any advice would be much appreciated.
Cheers,
-J
--
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Apache::DBI 0.94 - connect_on_init broken?
Posted by Larry Leszczynski <la...@emailplus.org>.
Hi Joshua -
On Tue, 14 Dec 2004, Joshua Hoblitt wrote:
> > PerlModule DBI
> > PerlModule Apache::DBI
Try swapping these - Apache::DBI must be loaded before DBI gets loaded.
When DBI loads, it checks to see if you're using Apache::DBI and does
internal magic if that is the case.
HTH,
Larry Leszczynski
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: Apache::DBI 0.94 - connect_on_init broken?
Posted by Joshua Hoblitt <jh...@ifa.hawaii.edu>.
After some experimentation, it seems that if I use load Apache::DBI while using
my own PerlChildInitHandler that indeed database connection that time out do
get reconnected (as expected). I'm still at a loss as to why 'connect_on_init'
does not work for me.
Cheers,
-J
--
On Tue, 14 Dec 2004, Joshua Hoblitt wrote:
> Hi Folks,
>
> This is my first serious attempt at working with mod_perl so please excuse me
> if this e-mail is a little naive.
>
> I have a SOAP::Transport::HTTP::Apache application that makes fairly heavy
> use
> of DBI. I would like to use Apache::DBI so I don't have to write my own
> logic
> for keep alives and reconnecting broken database handles. Unfortunately, the
> connect_on_init method does not seem to work for me.
>
> When I place this snippet in my Apache configuration my database (MySQL)
> reports that no database threads have been spawned.
>
> --
> PerlModule DBI
> PerlModule Apache::DBI
> .
> .
>
> <perl>
> Apache::DBI->connect_on_init(
> "DBI:mysql:database=foo:host=localhost",
> "foo",
> "foo",
> );
> </perl>
> --
>
> When I replace that with:
>
> --
> PerlModule My::Foo
> .
> .
>
> <perl>
> Apache->push_handlers(PerlChildInitHandler => sub {
> My::Foo->setup(
> "DBI:mysql:database=foo:host=localhost",
> "foo",
> "foo",
>> ;
> }
> );
> </perl>
> --
>
> Where ->setup is creating a database handle and storing it in a package
> variable. The database reports 64 threads (the number of Apache children at
> startup) active on the database. This has left me completely puzzled as
> Apache::DBI is also installing a PerChildInitHandler.
>
> I'm running this with Perl 5.8.5 on Apache 1.3.33/mod_perl 1.29.
>
> Any advice would be much appreciated.
>
> Cheers,
>
> -J
>
> --
>
> --
> Report problems: http://perl.apache.org/bugs/
> Mail list info: http://perl.apache.org/maillist/modperl.html
> List etiquette: http://perl.apache.org/maillist/email-etiquette.html
>
>
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html