Moved to dbi-dev as this is getting much more like a dev issue than
a general dbi-users issue.

On Thu, 20 Sep 2001, Tim Bunce wrote:
>On Wed, Sep 19, 2001 at 05:49:26PM -0700, Jonathan Leffler wrote:
>> On Wed, 19 Sep 2001, Tim Bunce wrote:
>> >On Wed, Sep 19, 2001 at 11:24:39AM -0500, James Maes wrote:
>> >> On Wednesday 19 September 2001 11:16 am, James Maes wrote:
>> >> > On Wednesday 19 September 2001 10:51 am, Tim Bunce wrote:
>> >> > > Actually the DBI uses a mutex *per driver* thus ensuring that
>> >> > > only a single thread can enter each driver.  But different
>> >> > > threads could go through the DBI into different drivers at the
>> >> > > same time.
>> >> > >
>> >> > > One subtle point to note: if multiple interpreters are being used
>> >> > > (such as mod_perl 2, or ActiveState's IIS thingy) then you can
>> >> > > have multiple DBI's and DBD::Foo's loaded.  One per perl
>> >> > > interpreter.  As the mutexes are per interpreter there's nothing
>> >> > > to stop two threads getting into the same underlying database
>> >> > > libraries via two separate perl+DBI+DBD::Foo's.
>> >> >
>> >> > Would it be possible for an application with multiple threads all
>> >> > working from the same driver be able to init N-threads, each thread
>> >> > with a separate connection to the database.  From what I see, that
>> >> > would be okay, but o two threads would be able to use their connect
>> >> > at the same time.  The driver forces everything to be
>> >> > synchronized...
>> >>
>> >> type-O ("but NO two threads....");
>> >
>> >Probably :)
>> >
>> >Trace level [mumble] adds thread mutex info to the trace output. Test it out.
>>
>> OK.  DBD::Informix currently does not expect to play threads.  It
>> handles multiple connections OK, and stores all the data for each
>> statement associated with the connection in the statement handle, so all
>> that should be fine.  You'd have to experiment to ensure that
>> DBD::Informix can be compiled in a threaded environment (basically,
>> making sure that there are enough "dThr;" declarations at the top of
>> functions to be safe.
>
>Actually it was dTHR I think. But I _think_ that kind of threading
>is deprecated in more recent versions of Perl which now use something
>called EXPLICIT_CONTEXT (from memory).

Oh?  How on earth (or any other appropriate venue - hell figured
in the first version of this sentence) are we, the poor dumb DBD
writers, to keep in touch which such things?  How are we even
supposed to know which bits of the Perl kernel we have to worry
about?  And, more particularly, what does 'more recent versions
of Perl' mean in this context.

Multi-threading is always tough.  If there is stuff that has to
be done to keep multi-threaded stuff safe, then we need to know
how to do that.  And it has to be simple - we are not all
multi-threading experts.

Also, I need to go back to Tim's comment:

    One subtle point to note: if multiple interpreters are being
    used (such as mod_perl 2, or ActiveState's IIS thingy) then
    you can have multiple DBI's and DBD::Foo's loaded.

So, each interpreter would have its own $drh for DBB::Foo.  With
such a scheme, DBD::Informix would not know that it needed to
generate distinct connection names between the interpreters, so
the different Perl interpreters would inevitably share connection
names, leading to confusion to all and sundry!  Is there a
recommended mechanism for this?  At the moment, there's a
function static variable in new_connection(), which is a file
static function in dbdimp.ec, that allocates the connection
number, which is used to generate the connection name.  Clearly,
the code could be revised to pull the connection number from the
$drh instead, but there'd still be a problem coordinating between
the different $drh's in the different interpreters.

This is nasty.  Really horridly complex.  Is there any mechanism
for dealing with multiple interpreters provided by Perl?  DBI?
Does each participating DBD writer have to find a mechanism for
dealing with this?

-- 
Yours,
Jonathan Leffler ([EMAIL PROTECTED]) #include <disclaimer.h>
Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN
     "I don't suffer from insanity; I enjoy every minute of it!"


Reply via email to