Snapshot Isolation provided by MVCC allows for `write skew` effects

Bug #121437 reported by Christian Theune
2
Affects Status Importance Assigned to Milestone
ZODB
Confirmed
Wishlist
Unassigned

Bug Description

The isolation level of ZODB only implements a relaxed version of the `Isolation` property of ACID.

Here is a sample where the serializability fails:

class X(object):
    set = None

    def add(self, x):
        if self.set is None:
            self.set = OOSet()
        set.add(x)

    def remove(self, x):
        if self.set is None:
            return
        if x in self.set:
            if len(self.set) == 1:
                self.set = None
            else:
                self.set.remove(x)

Now, consider the two transactions T1, T2, and T3, first in parallel:

T1: begin()
T1: root['x'] = X()
T1: root['x'].add(1)
T1: commit()

T2: begin()
T3: begin()
T2: root['x'].remove(1)
T3: root['x'].add(2)
T2: commit()
T3: commit()

All transactions will commit successfully and the value of root['x'].set will be None.

If we look at the transactions if they ran serialized:

(Same for T1)

T2: begin()
T2: root['x'].remove(1)
T2: commit()

T3: begin()
T3: root['x'].add(2)
T3: commit()

Now, the result would be root['x'].set == set([2]).

Note: The initial discussion for this bug was spawned by this mailing list thread (in German, sorry): https://mail.dzug.org/pipermail/zope/2007-June/003937.html

Revision history for this message
Jim Fulton (jim-zope) wrote : Re: [Bug 121437] Snapshot Isolation provided by MVCC allows for `write skew` effects

It's worth noting that most databases have the same property, at
least in their default configuration.

Jim

Changed in zodb:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Christian Theune (ctheune) wrote :

Here's a posting with some information how PostgreSQL approaches this: http://mail.zope.org/pipermail/zodb-dev/2008-January/011528.html

Revision history for this message
Christian Theune (ctheune) wrote :

Benji gave this URL for more information on possible solution strategies: http://en.wikipedia.org/wiki/Commitment_ordering#Multi-version_CO_.28MVCO.29

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.