[ZODB-Dev] Database conflict error

Chris Withers chris at simplistix.co.uk
Fri Apr 11 05:55:40 EDT 2008


Andrew Thompson wrote:
> I've been using the ZODB pretty intensively for a few weeks now, and
> suddenly have started getting intermittent Database conflict errors, after
> which calling conn.sync() makes no difference, and I cannot get back to the
> pre-exception state in one of my ZEO clients, although all the others
> continue quite happily.

I believe you're looking for:

from transaction import get
t = get()
t.abort()

> The error is :
> database conflict error (oid 0x029b, class btreelist.BTreeQueue, serial this
> txn started with 0x03750b64c9cf1f00 2008-04-11 08:36:47.299000, serial
> currently committed 0x03750b64ca57a788 2008-04-11 08:36:47.424000)

So, reading this more verbosely:
- the object with oid 0x029b was modified simultaneously on two
   different zeo clients
- when the transaction started on the zeo client where this error was
   raised, the object at 0x029b was committed at
   2008-04-11 08:36:47.299000
- when an attempt to commit this transaction was made, it was found this
   this committed time had changed to 2008-04-11 08:36:47.424000

As such, if this commit were to succeed, it would replace the data 
committed at 2008-04-11 08:36:47.424000, which would probably be a bad 
thing ;-)

(Imagine two people working on a text file over a network share: one 
saves, then the other saves, the changes made by the first person are 
lost, resulting in unhappiness allround ;-) )

> Question : What does the "conflict error" actually mean ?

See above...

> Question : All my other ZEO clients continue happily  -- and even this
> process works ***most*** of the time.  Short of dropping the ZEO connection
> and rejoining is there a way of resetting the ZEO session?

The "standard" way of dealing with conflict errors is to:

- abort the current transaction
- redo all the changes you'd made to objects in that transaction
- commit again

Pick an arbitary number of times to repeat this process (3 is often the 
magic number [1]) and if it still fails, let the conflict error 
percolate up...

cheers,

Chris

[1] http://www.seeklyrics.com/lyrics/De-La-Soul/The-Magic-Number.html

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk


More information about the ZODB-Dev mailing list