On Mon, Nov 25, 2002 at 10:14:55AM +0800, Autrijus Tang wrote:
> On Sun, Nov 24, 2002 at 08:20:44PM -0500, Lincoln Stein wrote:
> > On Sunday 24 November 2002 06:18 pm, Autrijus Tang wrote:
> > > Also I noticed that in Apache2 mod_perl1.99_07 Win2k Perl5.8
> > > DBD::mysql2.1020 DBI1.30, Tie::RDBM constantly produces this
> > > ithreads-related error:
> > >
> > > "->prepare failed: handle %d is owned by thread %x not current thread
> > > %x (%s)", "handles can't be shared between threads and your driver may need
> > > a CLONE method added"
> > >
> > > The statement that causes this is in line 330, _prepare():
> > >
> > > my $sth = $self->{'dbh'}->prepare($q);
> > >
> > > This is very strange since DBD::mysql does in fact have a CLONE
> > > method, and other frameworks (like DBIx::SearchBuilder) does not
> > > encouter such problems.
> > >
> > > Does it mean Tie::RDBM will need a CLONE method, or there is
> > > something obvious that I am missing?
> >
> > I haven't played much with ithreads. Would you be willing to look into this?
> > Lincoln
>
> Unfortunately I don't have much clues into ithreads DBI/DBD::mysql
> programming, either -- I have applied a workaround that have the
> Tie::RDBM object to do a new DBI->connect each time, which of course
> solved this problem, at a prohibitive cost.
Like the error message says "handles can't be shared between threads".
It is possible to implement a 'pool' of connections and let one be
'borrowed' by another thread, but I don't think anyone's worked on
implementing that.
http://www.google.com/search?as_q=dbi+thread+pool+apache+mod_perl&num=10&hl=en&ie=UTF-8&oe=UTF-8&as_epq=&as_oq=&as_eq=&lr=&as_ft=i&as_filetype=&as_qdr=all&as_occt=any&as_dt=i&as_sitesearch=&safe=off
Doug has worked on an Apache::DBIPool module but I *think* it predates
iThreads and the inter-interpreter sharing restriction it has:
http://perl.apache.org/~dougm/modperl_2.0.html#apache::dbipool
Although even it it won't work in it's current form, it would form
the basis of a working system once the DBI and drivers have a
standard way to 'borrow' the guts of another handle.
Tim.