[Dbix-class] Apache::DBI and DBIx::Class
Matt S Trout
dbix-class at trout.me.uk
Wed Apr 5 13:06:31 CEST 2006
Doran Barton wrote:
> I'm a relative newbie with DBIx::Class- but recently deployed a new web
> application using it. The application works great and thanks to DBIx::Class,
> it took less time to do.
>
> The application is implemented as mod_perl content handler. I am using
> Apache::DBI, as with other mod_perl applications, to maintain persistent
> connections to our PostgreSQL database. However, since deploying this
> application, we frequently exhaust our database connections. I think,
> perhaps, DBIx::Class is not taking advantage of Apache::DBI.
The problem is that if you open a handle before MP fork with Apache::DBI it
hangs onto it, resulting in all sorts of interesting explosions with
DBIx::Class, which then ends up with a duff connection handle.
As a result, in its quest to be fork- and thread- safe, DBIx::Class avoids
using the Apache::DBI connection stuff. I'm not sure how that would result in
exhausting db connections though since DBIx::Class keeps its connection
persistent so it should only need one per process/thread using it.
If you can recommend some sort of half-way house that allows DBIC to keep its
users from unexpected crashes but still supports Apache::DBI use, I'd be
interested to hear.
I can also think of two possible workarounds - (1) use sqlrelay for thread
pooling, (2) override Storage::DBI's connect() method to not route round
Apache::DBI and keep an eye on your connections yourself.
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Dbix-class
mailing list