"Elizabeth Mattijsen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> At 21:21 +0100 9/17/03, Nick Djurovich wrote:
> >I have a test perl script that opens a connection to a db. I was just
> >playing with threads to see if I could get 10 workers each with
> >their own db connection.
> >
> >The problem is that if just the threads instantiate a DB instance
> >its okay, if the main script instantiates a db handle beforehand,
> >it throws an error ;
>
> This is probably because the DBI driver builds some internal
> data-structures that can't stand being CLONEd when threads are
> started.
>
> You will need a DBD::Mysql driver that can stand being CLONEd.  I
> have no idea about the state of that.  Check the dbi-dev mailing list.
>
>
> Hope this helps.
>
>
> Liz


Hi Liz,

It's something I kind of checked, i read the DBD::mysql documentation,
here is a snippet from the Multithreading chapter ;

----------------------------------------------------------------------------
-
The multithreading capabilities of DBD::mysql depend completely on the
underlying C libraries: The modules are working with handle data only,
no global variables are accessed or (to the best of my knowledge)
thread unsafe functions are called. Thus DBD::mysql is believed to be
completely thread safe, if the C libraries are thread safe and you
don�t share handles among threads.

The obvious question is: Are the C libraries thread safe?  In the case
of MySQL the answer is "mostly" and, in theory, you should be able to
get a "yes", if the C library is compiled for being thread safe (By
default it isn�t.) by passing the option �with�thread�safe�client to
configure. See the section on How to make a threadsafe client in the
manual.

----------------------------------------------------------------------------
-

Now it it obviously doesn't say 'YES' it is thread safe, but the important
bit i've just noticed is where it says 'as long as you don't share handles
among threads'.

I don't understand why 10 threads each with their own DB connection
works, yet a connection made by MAIN in the perl script stops any
threads from making a new connection ? The fact that I can spawn
10 threads with their own DB connection means surely that it
*does* support CLONE ? or am i not understanding the underlying
principles correctly ?

Thanks for the tip, I will go and have a looking at the dbi-dev
mailing-list.

FYI: I'm using Redhat 8.0, perl: v5.8.0 built for i386-linux-thread-multi

--
Regards

Nick Djurovich

my opinions;


Reply via email to