mason-debugging_and_Apache::Session_problems

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.




===

From: "Jonathan Swartz" <swartz@pobox.com>
To: "'Robert Rendler'" <rendler@ozonline.com.au>,
Subject: RE: [Mason] Pages freeze
Date: Fri, 10 May 2002 06:36:11 -0700

Robert Rendler wrote: 

> I currently have pages that do not load at all, basically one
> page may load then when trying to go elsewhere in the site it
> doesn't. I've also noticed that it another apache process
> that just hangs there when this happens. This has been
> happening with 1.04 and 1.09_01 beta. I for the life of me
> cannot work out what is happening, I tried removing my
> autohandler to no avail. This also affects the simplest of
> pages. Any help would be greatly apreciated, I've also
> included my handler.pl. Thanks.
>
> #!/usr/bin/perl -w
> package HTML::Mason;
>
> # Bring in main Mason package.
> use lib '/home/username/perl/lib';
> use Apache::Registry;
> use Apache::AuthDBI;
> use Apache::Request;
> use HTML::Mason;
> use HTML::Mason::ApacheHandler;
> use DBI;
> use strict;
>
> # List of modules that you want to use from components (see Admin
> # manual for details)
> {  package HTML::Mason::Commands;
>    use vars qw(%session $dbh $sth $sql $generate_time);
>    use CGI::Cookie;
>    use Apache::Session::MySQL;
>    use Time::HiRes qw (gettimeofday tv_interval);
> }
>
> # Connect to database with Apache::DBI.
> #
> my ($db_type, $db_name, $db_user, $db_pass) = qw(mysql
> username username password);
> use Apache::DBI;
> Apache::DBI->connect_on_init("dbi:$db_type(AutoCommit=>1):$db_
> name", $db_user, $db_pass);
>
>
> # Create Mason objects
> #
> my $hostname = `/bin/hostname`;
> chomp $hostname;
>
> my $comp_root = '/home/username/www';
> $comp_root = '/var/www/username' if $hostname eq 'zippo';
>
> my $ah = HTML::Mason::ApacheHandler->new(
> 					    comp_root   => $comp_root,
> 					    data_dir    =>
> '/home/username/mason',
> 					    args_method => 'mod_perl'
> 					);
>
> # Activate the following if running httpd as root (the normal case).
> # Resets ownership of all files created by Mason at startup.
> #
> chown (Apache->server->uid, Apache->server->gid,
> $ah->interp->files_written);
>
> sub handler
> {
>     my ($r) = @_;
>
>     # If you plan to intermix images in the same directory as
>     # components, activate the following to prevent Mason from
>     # evaluating image files as components.
>     #
>     return -1 if $r->content_type && $r->content_type !~ m|^text/|io;
>
>     $HTML::Mason::Commands::dbh =
> DBI->connect("DBI:$db_type:$db_name", $db_user, $db_pass)
> 	or die "Couldn't connect to database: " . DBI->errstr;
>
>     my %cookies = parse CGI::Cookie($r->header_in('Cookie'));
>
>     # Don't even bother trying to use badly formed session ids.
>     my $sid;
>     if (defined $cookies{'session'} &&
> $cookies{'session'}->value() =~ /^[a-z\d]+$/ ) {
> 	$sid = $cookies{'session'}->value();
>     }
>
>     # If $sid is not defined this will generate a new session.
>     eval {
> 	tie %HTML::Mason::Commands::session,
> 'Apache::Session::MySQL', $sid, {
> 	    Handle => $HTML::Mason::Commands::dbh,
> 	    LockHandle => $HTML::Mason::Commands::dbh
> 	};
> 	# tie %HTML::Mason::Commands::session,
> 'Apache::Session::File', $sid;
>     };
>
>     if ( $@ ) {
> 	if ( $@ =~ /Object does not exist in the data store/ &&
> defined $sid ) {
> 	    # Attempt to create a new session if the previous one was
> 	    # not valid.  This attempt will die (leading to a 500
> 	    # error) if it fails.  Use eval {} to trap this if you so
> 	    # desire.
> 	    tie %HTML::Mason::Commands::session,
> 'Apache::Session::MySQL', undef, {
> 		Handle => $HTML::Mason::Commands::dbh,
> 		LockHandle => $HTML::Mason::Commands::dbh
> 	    };
> 	    # tie %HTML::Mason::Commands::session,
> 'Apache::Session::File', undef;
> 	} else {
> 	    # This means that we got a different error or we were
> 	    # attempting to create a new session from scratch.
> 	    die $@;
> 	}
>     }
>
>     # Always send the cookie out as there is no reason not to.
>     my $cookie = new CGI::Cookie(-name  => 'session',
> 				 -value =>
> $HTML::Mason::Commands::session{_session_id},
> 				 -expires => '+1y',
> 				 -path  => '/'
> 			 	);
>     $r->header_out('Set-Cookie' => $cookie);
>
>     my $status = $ah->handle_request($r);
>
>     untie %HTML::Mason::Commands::session;
>
>     return $status;
> }
>
> 1;
>
> --
> `$^Xdoc -qj`=~/"(.*)"/&&print"$1 named rob"





Robert - I suggest remove things one at a time, then trying to reproduce the
problem, until finally removing something enables the server to run
smoothly. This is assuming that it's relatively easy to replicate the
prolem.

Also see
http://perl.apache.org/guide/debug.html#Hanging_Processes_Detection_and for
ways of investigating hanging processes.


===

From: Dave Rolsky <autarch@urth.org>
To: Robert Rendler <rendler@ozonline.com.au>
Subject: Re: [Mason] Pages freeze
Date: Fri, 10 May 2002 10:20:29 -0500 (CDT)

On Fri, 10 May 2002, Robert Rendler wrote:

> I currently have pages that do not load at all, basically one page may
> load then when trying to go elsewhere in the site it doesn't. I've also
> noticed that it another apache process that just hangs there when this
> happens. This has been happening with 1.04 and 1.09_01 beta. I for the
> life of me cannot work out what is happening, I tried removing my
> autohandler to no avail. This also affects the simplest of pages. Any
> help would be greatly apreciated, I've also included my handler.pl.

John already gave at least one good suggestion.  Also make sure that
you're running an Apache with a static mod_perl (which is known to be most
stable) and do your testing in single-user mode (start apache with -X) so
that you can see if it always freezes after a certain number of requests.

strace may be useful, as recommended in the mod_perl guide, as could the
SIGUSR2 trick described there.

===

From: Robert Rendler <rendler@ozonline.com.au>
To: mason-users@lists.sourceforge.net
Subject: Re: [Mason] Pages freeze
Date: Sun, 12 May 2002 03:14:03 +1000

On Fri, 10 May 2002 10:20:29 -0500 (CDT)
Dave Rolsky <autarch@urth.org> wrote:

> On Fri, 10 May 2002, Robert Rendler wrote:
> 
> > I currently have pages that do not load at all, basically one page may
> > load then when trying to go elsewhere in the site it doesn't. I've also
> > noticed that it another apache process that just hangs there when this
> > happens. This has been happening with 1.04 and 1.09_01 beta. I for the
> > life of me cannot work out what is happening, I tried removing my
> > autohandler to no avail. This also affects the simplest of pages. Any
> > help would be greatly apreciated, I've also included my handler.pl.
> 
> John already gave at least one good suggestion.  Also make sure that
> you're running an Apache with a static mod_perl (which is known to be most
> stable) and do your testing in single-user mode (start apache with -X) so
> that you can see if it always freezes after a certain number of requests.
> 
> strace may be useful, as recommended in the mod_perl guide, as could the
> SIGUSR2 trick described there.
> 
> 

Thanks for that, I managed to find the problem (I think with the SIGUSR2
method). The results I have are as follows:

[Sun May 12 03:05:47 2002] [error] caught SIGUSR2! at /var/www/rendler/perl/handler.pl line 4
	main::__ANON__('USR2') called at /usr/share/perl5/Apache/Session/Lock/MySQL.pm line 54
	Apache::Session::Lock::MySQL::acquire_read_lock('Apache::Session::Lock::MySQL=HASH(0x862d6a8)', 'Apache::Session::MySQL=HASH(0x862d510)') called at /usr/share/perl5/Apache/Session.pm line 559
	Apache::Session::acquire_read_lock('Apache::Session::MySQL=HASH(0x862d510)') called at /usr/share/perl5/Apache/Session.pm line 479
	Apache::Session::restore('Apache::Session::MySQL=HASH(0x862d510)') called at /usr/share/perl5/Apache/Session.pm line 392
	Apache::Session::TIEHASH('Apache::Session::MySQL', 'c13d0c9036d1ec1a9bf4bae478cd5547', 'HASH(0x86318dc)') called at /var/www/rendler/perl/handler.pl line 76
	eval {...} called at /var/www/rendler/perl/handler.pl line 75
	HTML::Mason::handler('Apache=SCALAR(0x862ba74)') called at /dev/null line 0
	eval {...} called at /dev/null line 0

Any tips on how I could possibly fix this? Thanks.


===

From: Dave Rolsky <autarch@urth.org>
To: Robert Rendler <rendler@ozonline.com.au>
Subject: Re: [Mason] Pages freeze
Date: Sat, 11 May 2002 12:47:11 -0500 (CDT)

On Sun, 12 May 2002, Robert Rendler wrote:

> [Sun May 12 03:05:47 2002] [error] caught SIGUSR2! at /var/www/rendler/perl/handler.pl line 4
> 	main::__ANON__('USR2') called at /usr/share/perl5/Apache/Session/Lock/MySQL.pm line 54
> 	Apache::Session::Lock::MySQL::acquire_read_lock('Apache::Session::Lock::MySQL=HASH(0x862d6a8)', 'Apache::Session::MySQL=HASH(0x862d510)') called at /usr/share/perl5/Apache/Session.pm line 559
> 	Apache::Session::acquire_read_lock('Apache::Session::MySQL=HASH(0x862d510)') called at /usr/share/perl5/Apache/Session.pm line 479
> 	Apache::Session::restore('Apache::Session::MySQL=HASH(0x862d510)') called at /usr/share/perl5/Apache/Session.pm line 392
> 	Apache::Session::TIEHASH('Apache::Session::MySQL', 'c13d0c9036d1ec1a9bf4bae478cd5547', 'HASH(0x86318dc)') called at /var/www/rendler/perl/handler.pl line 76
> 	eval {...} called at /var/www/rendler/perl/handler.pl line 75
> 	HTML::Mason::handler('Apache=SCALAR(0x862ba74)') called at /dev/null line 0
> 	eval {...} called at /dev/null line 0
>
> Any tips on how I could possibly fix this? Thanks.

Um, don't use the MYSQL locking code that comes with Apache::Session ;)

Seriously, just try a different locking module (or maybe the NullLocker
module).

I myself have never had good luck with that particular locking module
either.

===

From: Robert Rendler <rendler@ozonline.com.au>
To: mason-users@lists.sourceforge.net
Subject: Re: [Mason] Pages freeze
Date: Mon, 13 May 2002 00:06:46 +1000

On Sat, 11 May 2002 12:47:11 -0500 (CDT)
Dave Rolsky <autarch@urth.org> wrote:

> On Sun, 12 May 2002, Robert Rendler wrote:
> 
> > [Sun May 12 03:05:47 2002] [error] caught SIGUSR2! at
> > /var/www/rendler/perl/handler.pl line 4	main::__ANON__('USR2') called
> > at /usr/share/perl5/Apache/Session/Lock/MySQL.pm line 54
> > Apache::Session::Lock::MySQL::acquire_read_lock('Apache::Session::Lock::My
> > SQL=HASH(0x862d6a8)', 'Apache::Session::MySQL=HASH(0x862d510)') called at
> > /usr/share/perl5/Apache/Session.pm line 559
> > Apache::Session::acquire_read_lock('Apache::Session::MySQL=HASH(0x862d510)
> > ') called at /usr/share/perl5/Apache/Session.pm line 479
> > Apache::Session::restore('Apache::Session::MySQL=HASH(0x862d510)') called
> > at /usr/share/perl5/Apache/Session.pm line 392
> > Apache::Session::TIEHASH('Apache::Session::MySQL',
> > 'c13d0c9036d1ec1a9bf4bae478cd5547', 'HASH(0x86318dc)') called at
> > /var/www/rendler/perl/handler.pl line 76	eval {...} called at
> > /var/www/rendler/perl/handler.pl line 75
> > HTML::Mason::handler('Apache=SCALAR(0x862ba74)') called at /dev/null line 0
> > eval {...} called at /dev/null line 0
> >
> > Any tips on how I could possibly fix this? Thanks.
> 
> Um, don't use the MYSQL locking code that comes with Apache::Session ;)
> 
> Seriously, just try a different locking module (or maybe the NullLocker
> module).
> 
> I myself have never had good luck with that particular locking module
> either.
> 

The MasonHQ website seems to implement session handling itself, I'm wondering
if this sort of problem is one of the reason why Apache::Session wasn't used.


===

From: "Jonathan Swartz" <swartz@pobox.com>
To: "'Robert Rendler'" <rendler@ozonline.com.au>,
Subject: RE: [Mason] Pages freeze
Date: Sun, 12 May 2002 07:28:19 -0700

> The MasonHQ website seems to implement session handling
> itself, I'm wondering
> if this sort of problem is one of the reason why
> Apache::Session wasn't used.

I found the problems caused by Apache::Session (there are many - search the
archive for this list) far outweighed the benefits, especially since I use a
database to store sessions and don't need the automatic tied-hash behavior.


_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users


===

From: Robert Rendler <rendler@ozonline.com.au>
To: mason-users@lists.sourceforge.net
Subject: Re: [Mason] Pages freeze
Date: Tue, 14 May 2002 17:06:47 +1000

On Sat, 11 May 2002 12:47:11 -0500 (CDT)
Dave Rolsky <autarch@urth.org> wrote:

> On Sun, 12 May 2002, Robert Rendler wrote:
> 
> > [Sun May 12 03:05:47 2002] [error] caught SIGUSR2! at
> > /var/www/rendler/perl/handler.pl line 4	main::__ANON__('USR2') called
> > at /usr/share/perl5/Apache/Session/Lock/MySQL.pm line 54
> > Apache::Session::Lock::MySQL::acquire_read_lock('Apache::Session::Lock::My
> > SQL=HASH(0x862d6a8)', 'Apache::Session::MySQL=HASH(0x862d510)') called at
> > /usr/share/perl5/Apache/Session.pm line 559
> > Apache::Session::acquire_read_lock('Apache::Session::MySQL=HASH(0x862d510)
> > ') called at /usr/share/perl5/Apache/Session.pm line 479
> > Apache::Session::restore('Apache::Session::MySQL=HASH(0x862d510)') called
> > at /usr/share/perl5/Apache/Session.pm line 392
> > Apache::Session::TIEHASH('Apache::Session::MySQL',
> > 'c13d0c9036d1ec1a9bf4bae478cd5547', 'HASH(0x86318dc)') called at
> > /var/www/rendler/perl/handler.pl line 76	eval {...} called at
> > /var/www/rendler/perl/handler.pl line 75
> > HTML::Mason::handler('Apache=SCALAR(0x862ba74)') called at /dev/null line 0
> > eval {...} called at /dev/null line 0
> >
> > Any tips on how I could possibly fix this? Thanks.
> 
> Um, don't use the MYSQL locking code that comes with Apache::Session ;)
> 
> Seriously, just try a different locking module (or maybe the NullLocker
> module).
> 
> I myself have never had good luck with that particular locking module
> either.
> 

I tried using Apache::Session::Flex and specified Null for the locking and all
seems fine now.

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@sourceforge.net
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users


===

From: Robert Rendler <rendler@ozonline.com.au>
To: mason-users@lists.sourceforge.net
Subject: Re: [Mason] Pages freeze
Date: Tue, 14 May 2002 18:21:05 +1000

On Tue, 14 May 2002 17:06:47 +1000
Robert Rendler <rendler@ozonline.com.au> wrote:

> On Sat, 11 May 2002 12:47:11 -0500 (CDT)
> Dave Rolsky <autarch@urth.org> wrote:
> 
> > On Sun, 12 May 2002, Robert Rendler wrote:
> > 
> > > [Sun May 12 03:05:47 2002] [error] caught SIGUSR2! at
> > > /var/www/rendler/perl/handler.pl line 4	main::__ANON__('USR2') called
> > > at /usr/share/perl5/Apache/Session/Lock/MySQL.pm line 54
> > > Apache::Session::Lock::MySQL::acquire_read_lock('Apache::Session::Lock::
> > > My SQL=HASH(0x862d6a8)', 'Apache::Session::MySQL=HASH(0x862d510)') called
> > > at/usr/share/perl5/Apache/Session.pm line 559
> > > Apache::Session::acquire_read_lock('Apache::Session::MySQL=HASH(0x862d51
> > > 0)') called at /usr/share/perl5/Apache/Session.pm line 479
> > > Apache::Session::restore('Apache::Session::MySQL=HASH(0x862d510)') called
> > > at /usr/share/perl5/Apache/Session.pm line 392
> > > Apache::Session::TIEHASH('Apache::Session::MySQL',
> > > 'c13d0c9036d1ec1a9bf4bae478cd5547', 'HASH(0x86318dc)') called at
> > > /var/www/rendler/perl/handler.pl line 76	eval {...} called at
> > > /var/www/rendler/perl/handler.pl line 75
> > > HTML::Mason::handler('Apache=SCALAR(0x862ba74)') called at /dev/null line
> > > 0 eval {...} called at /dev/null line 0
> > >
> > > Any tips on how I could possibly fix this? Thanks.
> > 
> > Um, don't use the MYSQL locking code that comes with Apache::Session ;)
> > 
> > Seriously, just try a different locking module (or maybe the NullLocker
> > module).
> > 
> > I myself have never had good luck with that particular locking module
> > either.
> > 
> 
> I tried using Apache::Session::Flex and specified Null for the locking and
> all seems fine now.
> 

Arg except now I notice it's creating a mysqld process for every request and
the process remains behind :(


===

From: Perrin Harkins <perrin@elem.com>
To: Robert Rendler <rendler@ozonline.com.au>
Subject: Re: [Mason] Pages freeze
Date: Tue, 14 May 2002 12:12:31 -0400

Robert Rendler wrote:
> Arg except now I notice it's creating a mysqld process for every request and
> the process remains behind :(

With Apache::DBI, you should get as many connections as you have Apache 
child processes.  I don't know how those connections will look on MySQL, 
but at least under Linux they will probably look like processes.


===

From: Robert Rendler <rendler@ozonline.com.au>
To: mason-users@lists.sourceforge.net
Subject: Re: [Mason] Pages freeze
Date: Wed, 15 May 2002 02:26:16 +1000

Perrin Harkins <perrin@elem.com> wrote:

> Robert Rendler wrote:
> > Arg except now I notice it's creating a mysqld process for every request
> > and the process remains behind :(
> 
> With Apache::DBI, you should get as many connections as you have Apache 
> child processes.  I don't know how those connections will look on MySQL, 
> but at least under Linux they will probably look like processes.


I've set it up to have 5 Apache processes but there are are a lot more mysqld
processes, max I have counted before restarting Apache was 50. But it seems to
be mysteriously fixed now that I have removed some unneeded modules from my
handler.pl.



===

From: "Lihn, Steve" <horng_twu_lihn@merck.com>
Subject: RE: [Mason] Pages freeze
To: "'swartz@pobox.com'" <swartz@pobox.com>,
Date: Tue, 14 May 2002 14:05:25 -0400

Jonathan Swartz [mailto:swartz@pobox.com] wrote: 

> > The MasonHQ website seems to implement session handling
> > itself, I'm wondering
> > if this sort of problem is one of the reason why
> > Apache::Session wasn't used.

> I found the problems caused by Apache::Session (there are
> many - search the archive for this list) far outweighed
> the benefits, especially since I use a database to store
> sessions and don't need the automatic tied-hash behavior.


I am very surprised to hear this. I thought Apache::Sesion
is the recommended way of managing session. (I am thinking
using Apache::Session::MySQL)

Can you elaborate a little bit?

  Steve Lihn

===


the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu