Hello,
I am seeing an issue where it appears that the contents of pnotes does
not get destroyed when code is run inside of Apache::Registry. I first
noticed this when I saw that connections to our db remained open after
a request was finished (we store the dbi handle in pnotes for
inter-request caching). Are there times when pnotes is expected not to
be destroyed? This same example works correctly when placed in a method
handler.
I'm running perl 5.8, mod_perl 1.27, Apache 1.3.27, and a stock RedHat
Linux 7.3 install on a vanilla x86 desktop.
Here is a really simple snippet that shows the "problem" (I just may
not understand how pnotes works).
my $r = Apache->request();
my $dbh = DBI->connect("DBI:mysql:database=blah blah blah...");
$r->pnotes("our_dbh_cache" => $dbh);
# Test destruction with a simpler case also
my $lemming = Lemming->new();
$r->pnotes("lemming" => $lemming);
$r->pnotes("lemming" => undef) if 0; #if 1 then destroy is never called
$r->send_http_header();
$r->print("Hello");
package Lemming;
sub new {
my $class = shift;
return bless {}, $class
}
sub DESTROY {
warn ("Aieee!!!");
}
1;
If the "if 0" is changed to "if 1" then it works as I expect and
"Aieee!!!" is dumped to the error log at the end of the request. If it
is run as written, then under Apache::Registry Lemming::DESTROY is
never called and the db connection sticks around indefinitely.
I can work around this particular instance of the problem pretty
easily. We can use Apache::DBI and we will only ever have one
connection sticking around (as it is now there is a connection per
request which is pretty awful), or we could just not cache the dbh.
That example is from old code and we don't care about it too much. The
real reason I'm mailing this list is that I'm seeing problems elsewhere
in our full system built with method handlers rather than
Apache::Registry. In that system data stored in pnotes may also be
leaking. I haven't been able to fully nail down those larger problems
enough yet to include any more detail, but I'm hoping this small
example will shed light on the larger issue.
Thanks for any help,
John
- Re: Sticky pnotes with Apache::Registry John Heitmann
- Re: Sticky pnotes with Apache::Registry John Heitmann
- Re: Sticky pnotes with Apache::Registry Joe Schaefer
- Re: Sticky pnotes with Apache::Registry David Kaufman
- Re: Sticky pnotes with Apache::Registry Perrin Harkins
- Sticky pnotes conclusion John Heitmann
- Re: Sticky pnotes conclusion Perrin Harkins
- Re: Sticky pnotes conclusion Ged Haywood