Re: Apache::DBI and PerlChildExitHandler
[prev]
[thread]
[next]
[Date index for 2004/12/21]
Joel wrote:
> Good morning,
>
> This is not a problem, per se, nor is it something I especially need to
> get done, but it would certainly be nice to have and might, in some small
> way, benefit the world in general. Here's what's going on:
>
>
> I am using mod_perl 1.99_13 (yes, I know I should upgrade) and Apache
> 2.0.52. I'm using Apache::DBI/DBD::Pg to connect to a PostgreSQL server.
>
> Everything works beautifully and the server is stable and everything like
> that. But my PostgreSQL server log file has a mess of these error
> messages:
>
> LOG: pq_recvbuf: unexpected EOF on client connection
>
> And from what I understand, this is caused when the Apache child exists
> and does not execute an explicit $dbh->disconnect() on the database
> handle. That is, the connection is not being closed properly before the
> handle goes out of scope.
>
> If this assumption is correct, I think it can be remedied by adding a
> PerlChildExitHandler to simply do a $dbh->disconnect() as the child is
> exiting.
>
> In general, this is not a problem. PostgreSQL logs the 'error' and goes
> about it's merry way. However, it would be nice to reduce the number of
> messages in the log file, since it's all noise and gets in the way of
> real errors.
>
> Can anyone comment on the feasability of this solution? I plan to
> implement it soon and if it works, provide a patch, but my brain is not
> thread-enabled (I'm using prefork), so I have no knowledge of how this
> would affect a threaded apache.
>
> The only nagging thing about this is why hasn't anyone thought of this
> and implemented it before? :) Or maybe I'm just WAY off-base.
PerlChildExitHandler should work, but why your application doesn't do that
by itself?
You could also subclass DBI::dbh (or whatever that class is) to implement
DESTROY which will do just that: $dbh->disconnect(). So when the object is
destroyed, it'll call disconnect.
Also it's possible that using Apache::DBI is the better solution, but it
depends on your demands.
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@xxxxxx.xxx http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
--
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 and PerlChildExitHandler
Stas Bekman 16:09 on 21 Dec 2004
|