On Wed, 2006-05-10 at 10:26 -0700, Jay Buffington wrote:
> At first I was caching the database handle myself when running outside
> of mod_perl.  In mod_perl I was relying on Apache::DBI returning the
> same handle every time I called connect().  That didn't work.

What didn't work about it?  If you use the same parameters, you should
always get the same handle.

> Then I read a section in Appendix A of "Practical mod_perl" that gave
> me what I wanted: http://modperlbook.org/html/appa_12.html
> 
> But doesn't that solution have this problem:  It will return a dead
> database handle when the connection times out before the Child is
> reaped.  In fact, that's just the problem that Apache::DBI solved by
> adding the ping() method.

Yes, that's not a good example.  It doesn't prevent connections from
being cached during startup either, or do automatic rollbacks, like
Apache::DBI does.

> I considered allocating a handle in the pnotes() at the beginning of
> every request using a PerlInitHandler, but that is expensive,
> especially since many requests don't even use a handle.

Are the requests that don't need a database running mod_perl code?  If
not, they should be served by a proxy.

- Perrin

Reply via email to