Re: [ZODB-Dev] Database conflict error

2008-04-20 Thread Chris McDonough
ZODB uses an "optimistic concurrency" model to deal with simultaneous changes to 
the same object from multiple connections.  In practice, this means your 
software needs to be willing to retry requests when they fail due to one of 
these errors.  Usually this means (in newer ZODBs), aborting the current 
transaction and starting a new one, replaying the action that caused the ZODB to 
fail with a conflict error.


- C


Andrew Thompson wrote:

Hi,
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 was using 3.7.0a0 and downloaded the 3.8 egg.  The behaviour remains the
same.

I am using a ZEO server with filestorage, and have tried rebuilding the
database from scratch, but the intermitent conflict error appears.

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)

BTreeQueue is a very simple wrapper over IOBTree.  Using integer keys.

Question : What does the "conflict error" actually mean ?
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?

Regards

Andrew Thompson





___
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


___
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] Database conflict error

2008-04-11 Thread Chris Withers

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
___
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