[ZODB-Dev] Re: Multi-Threading Transactions

Chris Spencer gmane.20.evilspam at spamgourmet.com
Thu Oct 13 02:44:34 EDT 2005


Andreas Jung wrote:
> 
> 
> --On 13. Oktober 2005 01:33:14 -0400 Chris Spencer 
> <gmane.20.evilspam at spamgourmet.com> wrote:
> 
>> Andreas Jung wrote:
>>
>>>
>>>
>>> --On 13. Oktober 2005 00:52:02 -0400 Chris Spencer
>>> <gmane.20.evilspam at spamgourmet.com> wrote:
>>>
>>>> If one thread writes to an object on one connection, and another thread
>>>> does the same on another connection, then one calls
>>>> transaction.commit(), will the all the changes in both connections be
>>>> commited? Is there a way for threads to maintain separate transactions?
>>>>
>>>>
>>>
>>> The first thread to commit wins. The second one will see a
>>> WriteConflictError exception. THat's how the ZDOB works: first come,
>>> first serve.
>>>
>>> -aj
>>
>>
>> I don't understand. How would two different threads, operating on
>> different data, committing at different times be in any sort of conflict?
>> I thought ZODB only raises a ConflictError when the same object is
>> written to by different threads?
> 
> 
> My remarks applies to the fact when you are writing to the *same* object 
> (that's how I read and understood your posting). If you writing to 
> different objects in different threads then all  transactions are 
> isolated...one of the basic features of databases.

I understand that, but my point was when you call transaction.commit(), 
you don't necessarily know what you're committing. One thread may be 
ready to commit. Another may not be. If one thread calls 
transaction.abort(), they may be aborting changes made by another 
thread. You'd have to write a complicated coordination mechanism to 
handle multi-threaded transactions to be sure. If threading is limited 
to connections, then wouldn't in make sense if transactions were as well?

Chris



More information about the ZODB-Dev mailing list