[cgiapp] cached DBI connections with cgiapp/fastcgi

Benjamin Hitz hitz at genome.stanford.edu
Wed Oct 22 13:33:51 EDT 2008


We are modifying our CGI::App to run under fastcgi/DBI/Oracle10g.
CGI::Application::Plugin::FastCGI seems to work not at all,

We use the "help" from this page: http://cgiapp.erlbaum.net/?FastCGI  
to pass the query params (uses CGI::Fast).

And in the cgiapp_init method we call:
$self->dbh_config(sub { Config::DB->dbh_cached });

Where Config::DB is a local module we have to configure database  
connections, schema names etc.
It basically calls DBI->connect_cached("dbi:Oracle:sdev2", $user,  
$pass, { RaiseError=>1, AutoCommit=>0, private_cachekey => $0 });

This works! [ Especially after I took out the cgiapp_postrun ($self- 
 >dbh->disconnect!!) ].

However... the database handle still eventually goes stale, and throws  
an oracle connection error.  I am still investigating how long this  
takes, but the web user has an IDLE parameter of 240 minutes in Oracle  
- I suspect this is when it gives up (right now all I know is that it  
was working when I left but not working when I came in in the AM)

So - I hope this is a useful summary for people who are still trying  
this - and also I am hoping that someone has some insight on why my  
$dbh goes stale.  It was my understanding that $self->dbh_config would  
reconnect if the handle went "bad" but probably I am misunderstanding  
something.

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