Is the DBIx::Class method better than Apache::DBI?
Presume that it is just a wrapper for the standard DBI stuff.
The problem that I have with connecting at server startup time, is that
our firewall drops connections to things that have been open for a while
but not used. So if nobody uses the server for an hour it is jammed. 1hr
cron restart - which is disgusting - is the only solution that I have
found.
My handler.pl sets the Apache::DBI configuration variables then a global
DB handle variable.
# always ping
Apache::DBI->connect_on_init($datasource, ...);
Apache::DBI->setPingTimeOut($datasource, 0);
{
package HTML::Mason::Commands;
use vars qw($DBH);
$DBH = DBI->connect(...);
}
Thanks
John
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark
Hedges
Sent: Saturday, 24 June 2006 7:52 AM
To: mason users list
Subject: Re: [Mason] Global object with database data
On Fri, 23 Jun 2006, Mark Hedges wrote:
> >
> > I don't believe it's possible for them to share the same connection
> > safely under FastCGI, since it is multi-process, just like mod_perl
with
> > the prefork MPM. The DBIx::Class code never shares connections
across
> > processes or threads.
>
> My impression was it was different, and that it does some kind
> of management for that, but I could be wrong.
>
> >From the man page:
>
> "It has auto-increment support for SQLite, MySQL, PostgreSQL,
> Oracle, SQL Server and DB2 and is known to be used in production
> on at least the first four, and is fork- and thread-safe out of
> the box (although your DBD may not be)."
I was wrong about DBIx::Class. All this means is, that if you
connect in startup, then children fork/spawn, DBIx::Class
detects that and automatically reconnects with a fresh handle.
There is some work on other mechanisms, if you search on CPAN
for "DBI pool". The DBI roadmap document has this to say:
"* Connection pooling in a threaded application, such as
mod_perl, is difficult because DBI handles cannot be passed
between threads. An alternative mechanism for passing
connections between threads has been defined, and an
experimental connection pool module implemented using it, but
development has stalled."
Until then, number of workers/threads == number of DBI handles.
Mark
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
--
Confidential: This email is intended only for the person or entity to
which it is addressed. The information contained in this email may be
confidential and privileged. Any retransmission, review, dissemination or
other use of, or taking of any action in reliance upon, this information
by persons or entities other than the intended recipient is prohibited.
If you received this email in error, please let us know by reply and
destroy all copies of it. Thank you.
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