[cgiapp] FastCGI/Oracle timeout issue

Benjamin Hitz hitz at genome.stanford.edu
Thu Aug 13 17:43:08 EDT 2009


So I have a little trouble with my CGIapp running under fastCGI.   
These are the only two apps I run under FastCGI (currently) so I don't  
have a huge amount of experience with it.

The phenotype is this:
Our Oracle users have a connection limit set (usually 4 hours or so) -  
including the user "WEBB" which the CGI scripts all use.
If a fastcgi/cgiapp script is unused for a long time (slightly greater  
than the time out) than the Oracle user logs out.  The CGI app (under  
fastcgi) then hangs, eternally cycling one of about 3 different error  
messages.

The error messages are caught in a run mode like this:

#######################################################################
sub setup {
#######################################################################

     my $self = shift;

     $self->start_mode('display_search_form');
...
}

#######################################################################
sub display_error {
#######################################################################
     my $self = shift;


     my $title = $self->{title} || "Error from CGI::Application $0";

     my %dataHash = ( page_title => $title,
		     errors     => \@_,
		     internal_url => $self->{URL},
		     external_url => $self->{extURL},
		     parameter    => { $self->query->Vars }
		   );

     $dataHash{errors} = $self->{error_message} if ($self- 
 >{error_message});

     return $self->tt_process('error.tmpl', \%dataHash);
}

I thought that I could try to catch the error in the main controller  
loop:

(WWW::Reports::LocusReport::LocusSummary ISA CGI::Application)0

while (my $q = CGI::Fast->new) {
     my $app = WWW::Reports::LocusReport::LocusSummary->new(QUERY => $q,
	                                                   tmpl_path => [
								     $ROOT_TMPL_PATH . "/Reports/LocusReport/LocusSummary",
								     $ROOT_TMPL_PATH . "/Reports/LocusReport",
								     $ROOT_TMPL_PATH . "/Reports",
								     $ROOT_TMPL_PATH
								     ],
						       );
     $app->run;

     die "Error found, killing process" if $app->{error_message};

}

But this doesn't appear to work... perhaps the object is cleansed  
between output and exit of $app->run?
I can just stick an exit or die in the display_error runmode method...  
but this results in a 500 error.  The good news is that after the 500  
error, a reload restarts the fastCGI process and gets a good result.

I would really like to catch this error and restart the process with a  
minimum of fuss.  I would be OK with showing the error.tmpl; I could  
add a reload to it or something.  I suppose some way of dropping the  
database handle and reconnecting would work.  I am using  
CGI::Application::Plugin::DBH and dbh_cached with DBD::Oracle.

Thanks,
Ben
--
Ben Hitz
Senior Scientific Programmer ** Saccharomyces Genome Database ** GO  
Consortium
Stanford University ** hitz at genome.stanford.edu





More information about the cgiapp mailing list