You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Kirk Bowe <ki...@kba.info> on 2002/10/15 21:40:15 UTC
Is there an easy way to trace / debug Apache::DBI (Postgres) leaks?
I'm using Apache::DBI connecting to a Postgres db. I'm using Template
Toolkit but no explicit db calls from within the templates -- they're all
done within the perl modules.
Unfortunately after a couple of hours of moderate use Postgres reaches its
max_clients level (which is set below max httpds in httpd.conf) and apache
has to be graceful'd to restore the situation. At this point there's no
work being done, so presumably the handles aren't being freed. I've made
sure that all db calls are fully read, e.g. doing while ($sth->fetch) {..}
routines on all selects so as to avoid leaving results unread.
Does anyone have any tips on how to, at this point, go about detecting
where the handle leak might be (which I'm presuming is the problem)? Or
should Template::Toolkit be avoided altogether when using mod_perl and
database connectivity? I'm using a 1.3 setup.
Cheers
Re: Is there an easy way to trace / debug Apache::DBI (Postgres) leaks?
Posted by Frank Wiles <fr...@wiles.org>.
.------[ Kirk Bowe wrote (2002/10/15 at 20:40:15) ]------
|
| I'm using Apache::DBI connecting to a Postgres db. I'm using Template
| Toolkit but no explicit db calls from within the templates -- they're all
| done within the perl modules.
|
| Unfortunately after a couple of hours of moderate use Postgres reaches its
| max_clients level (which is set below max httpds in httpd.conf) and apache
| has to be graceful'd to restore the situation. At this point there's no
| work being done, so presumably the handles aren't being freed. I've made
| sure that all db calls are fully read, e.g. doing while ($sth->fetch) {..}
| routines on all selects so as to avoid leaving results unread.
|
| Does anyone have any tips on how to, at this point, go about detecting
| where the handle leak might be (which I'm presuming is the problem)? Or
| should Template::Toolkit be avoided altogether when using mod_perl and
| database connectivity? I'm using a 1.3 setup.
|
`-------------------------------------------------
According to the Apache::DBI readme it seems that each apache child
will need one connection to the database, and the child will resuse
that connection for each request.
Have you turned on debugging in Apache::DBI and watched your Apache
error_log for any weirdness?
---------------------------------
Frank Wiles <fr...@wiles.org>
http://frank.wiles.org
---------------------------------
Re: posts headers and so on.
Posted by Per Einar Ellefsen <pe...@oslo.online.no>.
Hello Innerlab,
At 15:18 16.10.2002, Innerlab wrote:
>Hello:
>
>I just subscribed to the list. I don't want to be a pain in the ass
>so soon, but I've noticed that (at least on yahoo),
>these posts cannot be automatically replied to the list.
>They go by default to whoever wrote the original email, thus one has
>to manually replace that address for "modperl@apache.org" .
This is intentional. You have to use "Reply to all".
>Also, neither the "Subject", the "To:" or the "From:" information in
>the header doesn't mention "modperl * " , making it hard to filter
>these emails.
Use a filter that checks To: and Cc: for the presence of
modperl@perl.apache.org (which is btw the correct address), and filter
based on that.
--
Per Einar Ellefsen
pereinar@oslo.online.no
Re: posts headers and so on.
Posted by Issac Goldstand <ma...@beamartyr.net>.
I just hit reply now - note that it is AUTOMATICALLY to you, plus
modperl@apache.org
Also note the original headers below:
Issac
----- Original Message -----
From: "Innerlab" <in...@yahoo.com>
To: <mo...@apache.org>
Sent: Wednesday, October 16, 2002 3:18 PM
Subject: posts headers and so on.
> Hello:
>
> I just subscribed to the list. I don't want to be a pain in the ass
> so soon, but I've noticed that (at least on yahoo),
> these posts cannot be automatically replied to the list.
> They go by default to whoever wrote the original email, thus one has
> to manually replace that address for "modperl@apache.org" .
>
> Also, neither the "Subject", the "To:" or the "From:" information in
> the header doesn't mention "modperl * " , making it hard to filter
> these emails.
>
> Has anyone noticed all this already or is it me?
>
> =====
> ___________________
> Eduardo Gomez
> www.innerlab.com
>
> __________________________________________________
> Do you Yahoo!?
> Faith Hill - Exclusive Performances, Videos & More
> http://faith.yahoo.com
>
posts headers and so on.
Posted by Innerlab <in...@yahoo.com>.
Hello:
I just subscribed to the list. I don't want to be a pain in the ass
so soon, but I've noticed that (at least on yahoo),
these posts cannot be automatically replied to the list.
They go by default to whoever wrote the original email, thus one has
to manually replace that address for "modperl@apache.org" .
Also, neither the "Subject", the "To:" or the "From:" information in
the header doesn't mention "modperl * " , making it hard to filter
these emails.
Has anyone noticed all this already or is it me?
=====
___________________
Eduardo Gomez
www.innerlab.com
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
Re: Is there an easy way to trace / debug Apache::DBI (Postgres)
leaks?
Posted by Rafiq Ismail <ra...@bookings.nl>.
On Wed, 16 Oct 2002, Kirk Bowe wrote:
> my $dbh = DBI->connect ("dbi:Pg:dbname=hello", "postgres", "foo");
> my %orig = ();
> my @attrs = qw(AutoCommit RaiseError);
> $orig{$_} = $dbh->{$_} for @attrs;
> $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1;
>
> When I later do the $dbh->commit, it fails with this in my log file:
I've always done it this way, further the DBI man states:
Enable transactions (by turning "AutoCommit" off)
until the next call to "commit" or "rollback". After
the next "commit" or "rollback", "AutoCommit" will
automatically be turned on again.
Although I usually just do a $dbh->{AutoCommit}=1 to re-enable.
Are you sure that there isn't something else changing the AutoCommit back
on, unintentionally?
Rafiq
--
Senior Programmer
Bookings.nl
----------------------------------------------------------
Me::rafiq@dreamthought.com||www.dreamthought.com
Budget hosting on my 10Mbit/backbone::info@dreamthought.com
Re: Is there an easy way to trace / debug Apache::DBI (Postgres)
leaks?
Posted by Kirk Bowe <ki...@kba.info>.
Hi, thanks for the tips. But I don't seem to be able to locally override
the value of AutoCommit for one handle (I only need to use AutoCommit for
one script!). If I follow the instructions on the URL you pointed me to,
and do something like:
my $dbh = DBI->connect ("dbi:Pg:dbname=hello", "postgres", "foo");
my %orig = ();
my @attrs = qw(AutoCommit RaiseError);
$orig{$_} = $dbh->{$_} for @attrs;
$dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1;
When I later do the $dbh->commit, it fails with this in my log file:
commit ineffective with AutoCommit enabled at /usr/lib/perl5/.....
So is AutoCommit disallowed for overriding (as this seems to suggest)?
Regards
Kirk Bowe.
On Tue, 15 Oct 2002, Perrin Harkins wrote:
> Kirk Bowe wrote:
> > Unfortunately after a couple of hours of moderate use Postgres reaches its
> > max_clients level (which is set below max httpds in httpd.conf)
>
> This is usually caused by mistakes in your connection calls where they
> have slightly different connect info resulting in multiple connections.
>
> > At this point there's no
> > work being done, so presumably the handles aren't being freed.
>
> Database handles are not supposed to be freed. That's the point of
> Apache::DBI. However, you should only have one per httpd process.
>
> > Does anyone have any tips on how to, at this point, go about detecting
> > where the handle leak might be (which I'm presuming is the problem)?
>
> http://perl.apache.org/docs/1.0/guide/databases.html#Debugging_Apache__DBI
>
> > should Template::Toolkit be avoided altogether when using mod_perl and
> > database connectivity?
>
> TT is not related to this. It works great with mod_perl.
>
> - Perrin
>
Re: Is there an easy way to trace / debug Apache::DBI (Postgres)
leaks?
Posted by Perrin Harkins <pe...@elem.com>.
Kirk Bowe wrote:
> Unfortunately after a couple of hours of moderate use Postgres reaches its
> max_clients level (which is set below max httpds in httpd.conf)
This is usually caused by mistakes in your connection calls where they
have slightly different connect info resulting in multiple connections.
> At this point there's no
> work being done, so presumably the handles aren't being freed.
Database handles are not supposed to be freed. That's the point of
Apache::DBI. However, you should only have one per httpd process.
> Does anyone have any tips on how to, at this point, go about detecting
> where the handle leak might be (which I'm presuming is the problem)?
http://perl.apache.org/docs/1.0/guide/databases.html#Debugging_Apache__DBI
> should Template::Toolkit be avoided altogether when using mod_perl and
> database connectivity?
TT is not related to this. It works great with mod_perl.
- Perrin