[ZODB-Dev] Debugging ConflictErrors

Christian Robottom Reis kiko at async.com.br
Fri Jan 16 06:12:15 EST 2004


On Fri, Jan 16, 2004 at 10:46:34AM +0100, Thomas Guettler wrote:
> Am Donnerstag, 15. Januar 2004 17:12 schrieben Sie:
> > On Thu, Jan 15, 2004 at 05:02:24PM +0100, Thomas Guettler wrote:
> > > > I'm not sure I've said this before, but using the root object to hold a
> > > > large/variable number of objects is a Bad Idea. The root object is a
> > > > PersistentMapping, which provides no conflict isolation, and in the
> > > > long run it's almost impossible to do any write-intensive concurrent
> > > > work with one without generating an endless number of conflicts.
> > >
> > > Sorry, the was term "root object" was wrong. I meant the object
> > > which holds all my application. It is stored in conn.root()["server"]
> >
> > Well, what sort of object is *that*?
> 
> code:
>  class WorkflowServer(Persistent, HeaderAndFooter)
> HeaderAndFooter is a simple class 
> 
> > > This persistent object holds containers which store the data.
> >
> > IOW, what sort of container?
> 
> class HistoryContainer(Persistent):
>     def __init__(self, root):
>         self.root=root
>         self.history=[]
>     def append(self, historyEntry):
>         assert(historyEntry.__class__.__name__=="HistoryEntry")
>         self.history.append(historyEntry)
>         self._p_changed=1

Yeah, this is what I had suspected. You should *really* avoid using a
simple list to store objects, because it will be *very* conflict-prone
for the reason that *any* concurrent changes to it will conflict. This
is because the list is persisted atomically -- you can't change a part
of the list and just commit that part.

Ideally (as has been suggested before), you would use either a BTree or
a TreeSet to store your objects (i.e., HistoryContainer would be of one
of those types, or would *wrap* one of those types instead of a simple
list), which are much less likely to conflict. These are modified and
persisted in terms of buckets, which for any reasonably-sized BTree are
*much* smaller blobs to be discretely committed.

Take care,
--
Christian Robottom Reis | http://async.com.br/~kiko/ | [+55 16] 261 2331



More information about the ZODB-Dev mailing list