Stas Bekman wrote:
Hi,

As mod_perl 2 is going to be released shortly the issue with DBI and friends not being thread-safe (I believe DBI is fine, but DBDs are not) becomes a problem. Since Apache 2 has a bunch of threaded MPM implementations and while Unix users could always use prefork MPM (no threads) windows users can't afford this luxary, they need the modules to be thread-safe in order to use those.

So how hard will it be to bring the DBI world to the thread-safety? What are the issues that prevent us from getting there (besides the ever lacking tuits).

Thanks.


Probably the biggest issue is the thread safety of the underlying DBMS client API (for non-pure perl implementations), and the XS wrapper.

For those of us with Pure Perl drivers,
its a bit simpler: implement the CLONE method in the
driver, and make sure any global variables that might exist
are either shared or converted to instance (rather than
package/class) level variables. For "real" databases,
MySQL and Pg both have pure perl implementations, tho I'm
not certain how current they are, nor whether they've been tested
for thread safety at this point.

<plug type='shameless'>
DBD::Teradata (pure perl, commercial version)
has been thread safe for about a year now.
(Last tested with Perl 5.8.5 on Fedora Core 2)
</plug>

FWIW: Threaded perl performance seems to have improved
in Perl 5.8.5; in 5.8.3/4, it seemed mighty slow, both on
Windows and Linux. I haven't had a chance to test 5.8.6 yet.

However, Since $dbh's can't be shared between threads,
I wonder how Apache connection pools will behave in
such an environment (if at all) ?

Dean Arnold
Presicient Corp.

Reply via email to