Steve Schein wrote:
> Thank you for your efforts regarding API development for MySQL
> databases. I am currently using MySQL 4.0x on a Linux system and Perl
> v5.8. At the moment I'm using a generic DBI module (v1.38) and having
> trouble threads. The database won't connect on a new thread and
> "thread failed to start: DBD::mysql::dr connect failed: handle 1 is
> owned by thread 8454df8 not current thread 86bc3d0 (handles can't be
> shared between threads and your driver may need a CLONE method added) at
> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/DBI.pm line 585,
> <$client> line 1."
> The program runs fine unthreaded. Please let me know if you have a
> MySQL interface module that is thread safe.
I do not know, what you are specifying as "thread safe". The CLONE method,
which is required to share a handle between threads was added in DBD::mysql
2.1019, one year ago. I never tried whether it actually works, but I have no
reports that it doesn't, except yours.
DBI handles are not thread safe in the sense that they are reentrant. They
will never be, because they are typically related to network connections.
You cannot send 5 bytes of one request over the network, followed by then
bytes of a second request and 5 bytes of the next request. In other words:
You may share a handle between threads, but they must synchronize each other.
If your problem is reproducible, please be so kind to reduce it to a small
example script and post that to perl@stripped.
|• Re: MySQL||Jochen Wiedmann||19 Sep|