On Do, 2006-06-22 at 08:40 -0600, John Williams wrote:
> On Thu, 22 Jun 2006, Tobias Kremer wrote:
> >
> > Now I'd like to know if this could cause some sort of trouble because
> > I'm making a connection to the database during server startup
> 
> If your database happens to be down, you will not be able to start your
> web server either.  But you are down one way or the other anyway.

I was more thinking of issues regarding stale database handles (or
something else that might cause weird errors in the long run) because
they are initialized during server startup. I dug a little bit into
Apache::DBI and found out that it doesn't cache connections made during
startup - which is good.

> For $structure, you could 1) initialize it with each request, 2) always
> access $HTML::Mason::Commands::dbh, or 3) setup $self-{_dbh} as an alias
> to $HTML::Mason::Commands::dbh.

The main problem is: How to design a module which works completely on
its own as well as within mod_perl. The module should make a database
connection during object initialization (new). This connection should
then be used by all methods which want to access the database (because I
don't want to call "connect" before every database query). That's easy
under standalone conditions (connect within new, store the dbh in
$self->{_dbh} and use that in other methods).

Enter mod_perl. I'd like to initialize the object only ONCE during
server startup because there is some heavy startup processing going on
with data from the database which I don't want to be done on every
request. The final state (think data structures) should then be saved
within the object's attributes for later quick and easy retrieval during
the request phase. Now I hope you can see the problem: The handle
created during server startup will not be cached by Apache::DBI,
subsequent database queries to the database by the module will IMHO use
this non-cached connection which is _shared_ among all apache child
processes. AFAIK that's what could get me into serious trouble.

Any ideas?

Thanx!

Toby



Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to