[ZODB-Dev] Commit seems to succeed but does'nt

Steve Alexander steve@cat-box.net
Wed, 26 Sep 2001 15:47:12 +0100


Cyril Elkaim wrote:

>  Steve,
> 
>     Our problem is that two threads in our application never modify the 
> same objects (at least they shouldn't). In the code snippet we have 
> posted working there is two different sets. It was our understanding 
> that in this case there is no conflict. But apparently we were wrong.


Please post replies also to the zodb-dev mailing list. That way, others 
reading can learn from the conversation, and later from the mailing list 
archives.


Here's your answer from your code. In job1, you do this:


   root["JobOne" + str(i)] = "JobOne" + str(i)

In job2 you do this:

   root["JobTwo" + str(i)] = "JobTwo" + str(i)

both are modifying the root object, which I assume to be a 
PersistentMapping.

You could get around this by adding two PersistentMappings to root:

j1=root['JobOne']=PersistentMapping()
j2=root['JobTwo']=PersistentMapping()

Then, each job uses either j1 or j2, with no conflicts.


> Steve Alexander wrote:
> 
>> That wouldn't work in most cases. That's the point of a conflict 
>> error: there's a conflict between what threads want to do.
>>
>> You'll probably want to consider how you handle conflict errors at a 
>> "software architecture" level, rather than at an implementation level.
>> A good architecture will help you to keep the code elegant :)


--
Steve Alexander
Software Engineer
Cat-Box limited