Mark Hedges wrote:
> I tried to explain on the Mason list that DBIx::Class is "fork-
> and thread-safe" in a discussion on how (why not) to cache a
> DBI connection at Apache start-up.
>
> It occurred to me I don't really know what this means, and I
> couldn't find in previous discussions or the DBIC::Storage::DBI
> man page what actually happens.
>
> If I connect in the startup.pl, does that mean that each forked
> child shares the connection? (I'm guessing no.)
>
> If I connect in startup.pl under an Apache2 threaded worker
> model, does that mean each mod_perl thread shares the
> connection?
>
> How does this actually work under FastCGI?
>
> Is there any way for multiple processes or threads to really
> share a DBIC connection?
It's safe because it doesn't try and share the $dbh. If it detects a fork or
thread spawn, it dumps the $dbh and re-connects - meaning you can grab the
$schema at startup and everything will still Just Work (c.f.
Catalyst::Model::DBIC::Schema, for e.g.).
Well, unless you load Apache::DBI, in which case "good luck". I believe
they've finally fixed one showstopping bug in the last point release or two
but I still wouldn't trust it within a quarter mile of my code.
--
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/ +
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/