[ZODB-Dev] BTree set question

Dieter Maurer dieter at handshake.de
Sat Feb 28 05:06:48 EST 2004


Tim Peters wrote at 2004-2-26 17:33 -0500:
> ...
>I see that ChrisM explicitly asked for
>a use case where "two transactions assign the same new value to a single
>key" causes a problem, and I have that question too.

Here is a use case -- but not a convincing one(!)

     Suppose that you want to count something in the value
     of a key. This means, the application does:

	btree[key] += 1

     Now, when we have two concurrent transactions, both executing
     the code above, it is likely to be wrong to accept
     that both want to write the same value.

That said, it is unlikely that an application wants to count
in the value of a BTree item. If it really does, it should
use a datastructure made for counting, e.g. "BTrees.Length".


As Tim already pointed out, it is not difficult to construct an
application, that, given a set of conflict resolution rules (that
resolves some conflicts), will be unhappy with its resolution.

The application must know the applied resolution rules, and, if
necessary, use a different data structure with different resolution rules.
Therefore, it is vital that the resolution rules are quite stable
(and documented).


It would probably be helpful, when the resolution rules could be
customized in derived classes.
This might already be possible with ZODB 3.3 as conflict resolution
works on the "pickle" states and such states are accessible in
Python even for BTrees with their usually inaccessible internal
state.

-- 
Dieter



More information about the ZODB-Dev mailing list