Re: [ZODB-Dev] Concurrent transactions

2007-06-01 Thread Stefan H. Holek
Counting in the ZODB is more or less a no-go. You will get write  
conflicts, and your ZODB will grow (too) quickly. That said, you may  
want to look at BTrees.Length for a counter with built-in conflict  
resolution.


Stefan


On 1. Jun 2007, at 09:47, Kai Diefenbach wrote:


After reading some documentation about transactions, concurrency and
atomicity, I don't think that the following issue is a problem, but  
I'd
be nice to get confirmation from some exports. Or - of course -  
that it

doesn't behave in the way I think.

Within an adapter I increase a counter (e.g. for every download of an
file) by doing:

self.counter[0] += 1

self.counter is a PersistentList stored as annotation.

Could there be a problem with concurrent access to the counter? With
other words:


--
Anything that, in happening, causes something else to happen,
causes something else to happen.  --Douglas Adams


___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev


Re: [ZODB-Dev] Concurrent transactions

2007-06-01 Thread Benji York

Kai Diefenbach wrote:

Within an adapter I increase a counter (e.g. for every download of an
file) by doing: 

self.counter[0] += 1


self.counter is a PersistentList stored as annotation.


Note that if you use a PersistentList, then the entire list must be 
written to the database each time a non-Persistent element changes (or 
an item is added or removed from the list).  If the list is of any 
appreciably size, that will be bad.

--
Benji York
Senior Software Engineer
Zope Corporation
___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev