[Catalyst] DBIC model and mpm_winnt threads in MP2.0 Engine
Matt S Trout
dbix-class at trout.me.uk
Tue Mar 7 19:17:37 CET 2006
Ryan Parr wrote:
> I've just finished setting up Catalyst/MP2/Apache2 on a Windows 2003
> server. Everything is working until I attempt to use a model class.
> Any attempt throws the following exception:
>
> <error>
> Caught exception in MyApp::Controller::Scratch::DBICDump->default
> "DBD::mysql::db FETCH failed: handle 2 is owned by thread 1ca863c not
> current thread 19dba04 (handles can't be shared between threads and
> your driver may need a CLONE method added) at
> C:/OptSoftware/Perl/site/lib/DBIx/Class/Storage/DBI.pm line 125."
> </error>
>
> This happens whether I use $c->model('DB::Table') or
> MyApp::Model::DB::Table to instantiate, and regardless of whether or
> not there are relationships setup in the class.
>
> I can create a database handel using DBI directly without issue but
> simply cannot use the DBIx::Class model. Has anyone seen this issue?
> Easily solvable? The only result from a google search appears to be
> one other person asking the same question without response :)
Smells like it's trying to share the $dbh between threads. Try doing an
explicit ->storage->disconnect after you've finished setting up, as
documented at http://dev.catalyst.perl.org/wiki/SolvedIssues#si.85
DBIx::Class can figure out it's not in the same process anymore and
re-connect the $dbh but nobody's really looked into making the same
thing work cross-thread - maybe that's because people are asking on the
Catalyst list rather than the dbix-class list :)
More information about the Catalyst
mailing list