You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Boysenberry Payne <bo...@humaniteque.com> on 2005/08/24 15:53:50 UTC

Wondering about MP1 clean up

I've been having weirdness with errors in my error_log while stopping 
and starting
apache 1.3.33.  Basically I see:
[warn] child process 867 did not exit, sending another SIGHUP
for every process.  After which I get:
[notice] SIGHUP received.  Attempting to restart
Then it restarts.

I'm using an OS X box with MP 1.26 and have striped everything down to 
a basic
handler and still get the errors intermittently.  Someone on this list 
mentioned there
was a known apache 1.3.33/ MP 1.26 bug something to this effect.  I've 
resigned myself
to being ok with this.

After researching a little on Perl Monks someone said it might be 
circular references
and suggested I use Data::Dump to see whether I do or not.  Another 
thing that they
said I could do was put:
warn "Module Name was Destroyed";
in custom DESTROY blocks.  I tried it and found some of my modules 
weren't being
destroyed properly.  I was told I should look at the 'foo' => 
$VAR->{some_scalar} lines
as possible circular loops.  There were bunches of them.  Which in my 
situation is
pretty hard not to do using OOP.  I'm going through my code now step by 
step and
trying to minimize them, or delete them once they've been used.

My question actually comes from the warn "Module Destroyed" statements.

When I start up apache I usually get one on start up.  Is this the 
parent or root httpd?
Is it normal for it to clean up on start?

Am I missing an easier way to get my application tightened up?
Because the errors are only during start up and shut down I'm not to 
worried about
the error_log ballooning up, should I be?  I haven't noticed my httpd 
processes
ballooning in memory either, so I should be fine right?

Finally, when does mod_perl do clean up, shut down, each request, or 
both?

I hope this is a mod_perl question...

Thanks,
Boysenberry

boysenberrys.com | habitatlife.com | selfgnosis.com


Re: Wondering about MP1 clean up

Posted by Perrin Harkins <pe...@elem.com>.
On Wed, 2005-08-24 at 09:45 -0500, Boysenberry Payne wrote:
> So it would seem this is a circular reference right?
> How can I get the info I need in each of these without getting caught
> by this?

Some techniques are described here:
http://www.perl.com/pub/a/2002/08/07/proxyobject.html


> I've been using O'reilly books in particular the books in The Perl CD
> Bookshelf v3.0.
> They mentioned an "experimental" WeakRef module for weakening
> references
> to prevent the circular logic thing.  But I usually try and have my
> modules be the
> only "experimental" parts of my apps if possible.  I just found 13.13.
> Coping with Circular Data Structures
> in the Perl Cookbook, maybe that has my solution.

Scalar::Util::weaken is probably what you want.  Be aware of the age of
the books you're using.

- Perrin


Re: Wondering about MP1 clean up

Posted by Boysenberry Payne <bo...@humaniteque.com>.
On Aug 24, 2005, at 9:25 AM, Perrin Harkins wrote:

> I'm not sure what would be dangerous about that, but I guess there must
> be a larger context.

Here is an example I gave on Perl Monks for an example of my issue in a 
larger context:

package Base;
sub handler {

   my $this = {};
   bless $this;
   $this->{pac1} = new Package1;
   $this->{pac2} = new Package2( pac1 => $this->{pac1} );
   # print  Dumper $this
}

package Package2;

sub new {

   my $class = shift;
   my $this = {};
   bless( $this, $class );
   if (@_) {
     my %extra = @_;
     @$this{keys %extra} = values %extra;
   }
   my $pac1 = $this->{pac1};
   my $pac3 = new Package3( pac1 => $pac1 );
   @$this{pac3} = $pac3;
}

When handler's dumped with Data::Dump shows:
$VAR1 = bless({
   pac2 => bless({
     pac3 => bless({pac1 => bless({ some => "value" }, Package1 )}, Pac
+kage3),
     pac1 => $VAR1->{pac2}->{pac3}->{pac1}}, Package2),
   pac1 => $VAR1->{pac2}->{pac3}->{pac1}}, Base);

  So it would seem this is a circular reference right?
  How can I get the info I need in each of these without getting caught 
by this?


> What are you trying to tighten up?  Are you still just trying to get 
> rid
> of the warnings on shutdown?

Yes getting rid of the warnings, would help me sleep better...


> The phases of request handling are documented pretty well on the site
> and in various mod_perl books.  The interpreter won't be shut down 
> until
> the process exits, but that may be long before the server is shut down
> for a particular process.

I've been using O'reilly books in particular the books in The Perl CD 
Bookshelf v3.0.
They mentioned an "experimental" WeakRef module for weakening references
to prevent the circular logic thing.  But I usually try and have my 
modules be the
only "experimental" parts of my apps if possible.  I just found 13.13. 
Coping with Circular Data Structures
in the Perl Cookbook, maybe that has my solution.


Thanks,
Boysenberry

boysenberrys.com | habitatlife.com | selfgnosis.com

Re: Wondering about MP1 clean up

Posted by Perrin Harkins <pe...@elem.com>.
On Wed, 2005-08-24 at 08:53 -0500, Boysenberry Payne wrote:
> I'm using an OS X box with MP 1.26 and have striped everything down to 
> a basic
> handler and still get the errors intermittently.  Someone on this list 
> mentioned there
> was a known apache 1.3.33/ MP 1.26 bug something to this effect.  I've 
> resigned myself
> to being ok with this.

They don't sound like a real problem, but I don't get them, so I
wouldn't say you have to resign yourself to having them.

> I was told I should look at the 'foo' => 
> $VAR->{some_scalar} lines
> as possible circular loops.

I'm not sure what would be dangerous about that, but I guess there must
be a larger context.

> When I start up apache I usually get one on start up.  Is this the 
> parent or root httpd?
> Is it normal for it to clean up on start?

When an object goes out of scope, it gets DESTROYed.  This isn't the
whole parent process we're talking about, just one object.

> Am I missing an easier way to get my application tightened up?

What are you trying to tighten up?  Are you still just trying to get rid
of the warnings on shutdown?

> I haven't noticed my httpd 
> processes
> ballooning in memory either, so I should be fine right?

That's the major worry with circular refs, so if you don't see that, you
don't need to worry too much.

> Finally, when does mod_perl do clean up, shut down, each request, or 
> both?

The phases of request handling are documented pretty well on the site
and in various mod_perl books.  The interpreter won't be shut down until
the process exits, but that may be long before the server is shut down
for a particular process.

- Perrin


Re: Wondering about MP1 clean up

Posted by Boysenberry Payne <bo...@humaniteque.com>.
On Aug 24, 2005, at 9:19 AM, Philip M. Gollucci wrote:

> $Apache::DBI::DEBUG = 2;
> $Apache::AuthDBI::DEBUG = 2;

I put them in and didn't notice anything in the error_log.  Maybe I 
need to do something else?

Also, maybe I should mention it's any use statements in the startup.pl
that make the error reappear not just use Apache::DBI()

Thanks,
Boysenberry

boysenberrys.com | habitatlife.com | selfgnosis.com


Re: Wondering about MP1 clean up

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Boysenberry Payne wrote:
> There errors are gone.  If I add:
> use Apache::DBI();
> in startup.pl I get the errors again...
Try Setting in startup.pl
$Apache::DBI::DEBUG = 2;
$Apache::AuthDBI::DEBUG = 2;

and tail -f /server_root/error_log


-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com


Re: Wondering about MP1 clean up

Posted by Boysenberry Payne <bo...@humaniteque.com>.
On Aug 24, 2005, at 8:58 AM, Philip M. Gollucci wrote:
> What happens if you don't load any of YOUR code and just load mp1 with 
> a defacto startup.pl file.
> Again don't load any of YOUR code.

When I strip it down to just:

PerlRequire /etc/httpd/perl/startup.pl
<Location /perl>
	SetHandler perl-script
	PerlHandler Apache::Registry
	PerlSendHeader On
	Options ExecCGI
</Location>

startup.pl:

#!/usr/bin/perl
use Apache::Registry();

There errors are gone.  If I add:
use Apache::DBI();
in startup.pl I get the errors again...

Boysenberry

boysenberrys.com | habitatlife.com | selfgnosis.com


Re: Wondering about MP1 clean up

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Boysenberry Payne wrote:
> I'm using an OS X box with MP 1.26 and have striped everything down to a 
> basic
> handler and still get the errors intermittently.  Someone on this list 
> mentioned there
> was a known apache 1.3.33/ MP 1.26 bug something to this effect.  I've 
> resigned myself
> to being ok with this.
I believe that was me.

> After researching a little on Perl Monks someone said it might be 
> circular references
> and suggested I use Data::Dump to see whether I do or not.  Another 
> thing that they
> said I could do was put:
> warn "Module Name was Destroyed";
> in custom DESTROY blocks.  I tried it and found some of my modules 
> weren't being
> destroyed properly.  I was told I should look at the 'foo' => 
> $VAR->{some_scalar} lines
> as possible circular loops.  There were bunches of them.  Which in my 
> situation is
> pretty hard not to do using OOP.  I'm going through my code now step by 
> step and
> trying to minimize them, or delete them once they've been used.
What happens if you don't load any of YOUR code and just load mp1 with a defacto startup.pl file.
Again don't load any of YOUR code.

> 
> My question actually comes from the warn "Module Destroyed" statements.
> 
> When I start up apache I usually get one on start up.  Is this the 
> parent or root httpd?
Depends, you could fire up gdb and check it out.  Though I don't know how that will pan out on OS X.
% gdb httpd
gdb>run -X -d /path/to/serverroot

-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com