[ZODB-Dev] newbie ZEO first try. ConflictError.

tsmiller tsmiller at gnixterhouse.com
Thu Nov 26 16:02:55 EST 2009


Laurence,
There are three things.  First, though I am writing to the same object, I am
only doing a write every 10 seconds.  That is an eternity in cpu time.  I
would not expect many conflicts to occur in eternity.  Secondly, the
conflict happens EVERY time from whichever program was started first.  There
is no randomness to it.  Third, I start the second program a few seconds
after the first, so there should be an offset of when each program writes to
the database.  

I have looked at the chatter page that you referred me to, but It is the way
that I do things to start small.  And small in this case means to be able to
write to a ZEO database from two programs without a conflict.  What you said
doesn't make sense to me.  I would appreciate it if you could expound some
to help me understand why.    

thanks again,

tom 



Laurence Rowe wrote:
> 
> With that setup, you would expect a lot of conflicts, you are
> continually writing to the same object from more than one client. You
> will see many fewer conflicts if the different clients wrote to
> different objects or updated an object with conflict resolution (for
> instance inserting into a BTree).
> 
> You may find the example application at
> http://docs.zope.org/zodb/zodbguide/zeo.html#sample-application-chatter-py
> helpful. I've updated the conflict handling and links, but it will
> take a few hours for the update to be published to the website. In the
> meantime it may be downloaded from svn:
> http://svn.zope.org/zodbdocs/trunk/zodbguide/chatter.py?view=auto
> helpful.
> 
> Laurence
> 
> 2009/11/26 tsmiller <tsmiller at gnixterhouse.com>:
>>
>> Laurence,
>> Thank you for your very quick reply.  I did as you suggested and now the
>> ConflictError is now handled.  And that is a most excellent thing because
>> now ConflictError is raised every time.  So it still seems to be
>> confused.
>> I am trying to figure out if I will be able to use ZEO in my application.
>>
>> Now my program reads:
>>
>> while True:
>>        root[ "one" ] = time.asctime()
>>        while True:
>>                try:
>>                        print "Try to commit transaction"
>>                        transaction.commit()
>>                        print "root is",  root
>>                except POSException.ConflictError:
>>                        print "we have a conflict"
>>                        transaction.abort()
>>                        time.sleep(.2)
>>                else:
>>                        break
>>
>>        time.sleep(10)
>>
>>
>> And the output is:
>>
>> // the program is only running once here
>> Try to commit transaction
>> root is {'one': 'Thu Nov 26 11:37:53 2009'}
>> Try to commit transaction
>> root is {'one': 'Thu Nov 26 11:38:03 2009'}
>> Try to commit transaction
>> root is {'one': 'Thu Nov 26 11:38:13 2009'}
>> Try to commit transaction
>> root is {'one': 'Thu Nov 26 11:38:23 2009'}
>> Try to commit transaction
>> root is {'one': 'Thu Nov 26 11:38:33 2009'}
>>
>> // after I start a second copy, the first copy always has a conflict (
>> the
>> second copy does not get this conflict error).
>> Try to commit transaction
>> we have a conflict
>> Try to commit transaction
>> root is {'one': 'Thu Nov 26 11:38:35 2009'}
>> Try to commit transaction
>> we have a conflict
>> Try to commit transaction
>> root is {'one': 'Thu Nov 26 11:38:46 2009'}
>> Try to commit transaction
>> we have a conflict
>> Try to commit transaction
>> root is {'one': 'Thu Nov 26 11:38:56 2009'}
>> Try to commit transaction
>> we have a conflict
>>
>> thanks,
>> tom
>>
>>
>>
>> Laurence Rowe wrote:
>>>
>>> You must be prepared to abort and retry the whole transaction:
>>>
>>>    while True:
>>>            while True:
>>>                    try:
>>>                            root[ "one" ] = time.asctime()
>>>                            transaction.commit()
>>>                    except POSException.ConflictError:
>>>                            transaction.abort()
>>>                            time.sleep(.2)
>>>                    else:
>>>                            break
>>>
>>>            time.sleep(10)
>>>
>>>
>>> Laurence
>>>
>>> 2009/11/26 tsmiller <tsmiller at gnixterhouse.com>:
>>>>
>>>> ZODB Developers,
>>>>
>>>> Can you please tell me what I am doing wrong in my first simple attempt
>>>> to
>>>> make use of ZEO.  My ZODB and ZEO are both the same version (3.6.0).
>>>>
>>>> First, I start my ZEO server and it looks like it starts properly:
>>>>
>>>> python2.4 /usr/lib/python2.4/site-packages/ZEO/runzeo.py -a
>>>> localhost:9100
>>>> -f /home/tom/zeo/test.fs
>>>>
>>>> ------
>>>> 2009-11-26T00:05:14 INFO ZEO.runzeo (8192) opening storage '1' using
>>>> FileStorage
>>>> ------
>>>> 2009-11-26T00:05:14 INFO ZEO.StorageServer (8192) StorageServer created
>>>> RW
>>>> with storages: 1:RW:/home/tom/zeo/test.fs
>>>> ------
>>>> 2009-11-26T00:05:14 INFO ZEO.zrpc (8192) listening on ('localhost',
>>>> 9100)
>>>>
>>>>
>>>> Second, I start my client, twice.  The purpose is to write to the same
>>>> test.fs file from both of them.  The idea is to loop continuously,
>>>> writing
>>>> to test.fs from each program.  If I only start the program once, it
>>>> writes
>>>> to test.fs fine.  But the first time it tries to commit a transaction
>>>> after
>>>> starting a second copy of the program, it always gives an error.
>>>>
>>>>    from ZEO import ClientStorage
>>>>    from ZODB import DB
>>>>    from ZODB import POSException
>>>>    import transaction
>>>>    import time
>>>>
>>>>    addr = 'localhost', 9100
>>>>    storage = ClientStorage.ClientStorage( addr )
>>>>    db = DB(storage)
>>>>    conn = db.open()
>>>>    root = conn.root()
>>>>    while True:
>>>>            root[ "one" ] = time.asctime()
>>>>            while True:
>>>>                    try:
>>>>                            transaction.commit()
>>>>                    except POSException.ConflictError:
>>>>                            time.sleep(.2)
>>>>                    else:
>>>>                            break
>>>>
>>>>            time.sleep(10)
>>>>
>>>>
>>>> The traceback folows. The conflict error is not handled and I don't
>>>> know
>>>> why.    I am sure that I am missing something simple.
>>>>
>>>> we have a conflict
>>>> Traceback (most recent call last):
>>>>  File "zeotest.py", line 17, in ?
>>>>    transaction.commit()
>>>>  File "/usr/lib/python2.4/site-packages/transaction/_manager.py", line
>>>> 96,
>>>> in commit
>>>>    return self.get().commit(sub, deprecation_wng=False)
>>>>  File "/usr/lib/python2.4/site-packages/transaction/_transaction.py",
>>>> line
>>>> 370, in commit
>>>>    self._prior_operation_failed() # doesn't return
>>>>  File "/usr/lib/python2.4/site-packages/transaction/_transaction.py",
>>>> line
>>>> 250, in _prior_operation_failed
>>>>    raise TransactionFailedError("An operation previously failed, "
>>>> ZODB.POSException.TransactionFailedError: An operation previously
>>>> failed,
>>>> with traceback:
>>>>
>>>>  File "zeotest.py", line 17, in ?
>>>>    transaction.commit()
>>>>  File "/usr/lib/python2.4/site-packages/transaction/_manager.py", line
>>>> 96,
>>>> in commit
>>>>    return self.get().commit(sub, deprecation_wng=False)
>>>>  File "/usr/lib/python2.4/site-packages/transaction/_transaction.py",
>>>> line
>>>> 380, in commit
>>>>    self._saveCommitishError() # This raises!
>>>>  File "/usr/lib/python2.4/site-packages/transaction/_transaction.py",
>>>> line
>>>> 378, in commit
>>>>    self._commitResources()
>>>>  File "/usr/lib/python2.4/site-packages/transaction/_transaction.py",
>>>> line
>>>> 433, in _commitResources
>>>>    rm.commit(self)
>>>>  File "/usr/lib/python2.4/site-packages/ZODB/Connection.py", line 484,
>>>> in
>>>> commit
>>>>    self._commit(transaction)
>>>>  File "/usr/lib/python2.4/site-packages/ZODB/Connection.py", line 518,
>>>> in
>>>> _commit
>>>>    raise ConflictError(object=obj)
>>>> ConflictError: database conflict error (oid 0x00, class
>>>> persistent.mapping.PersistentMapping)
>>>>
>>>>
>>>> thanks,
>>>>
>>>> tom
>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/newbie-ZEO-first-try.--ConflictError.-tp26532984p26532984.html
>>>> Sent from the Zope - ZODB-Dev mailing list archive at Nabble.com.
>>>>
>>>> _______________________________________________
>>>> For more information about ZODB, see the ZODB Wiki:
>>>> http://www.zope.org/Wikis/ZODB/
>>>>
>>>> ZODB-Dev mailing list  -  ZODB-Dev at zope.org
>>>> https://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 at zope.org
>>> https://mail.zope.org/mailman/listinfo/zodb-dev
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/newbie-ZEO-first-try.--ConflictError.-tp26532984p26533587.html
>> Sent from the Zope - ZODB-Dev mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> For more information about ZODB, see the ZODB Wiki:
>> http://www.zope.org/Wikis/ZODB/
>>
>> ZODB-Dev mailing list  -  ZODB-Dev at zope.org
>> https://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 at zope.org
> https://mail.zope.org/mailman/listinfo/zodb-dev
> 
> 

-- 
View this message in context: http://old.nabble.com/newbie-ZEO-first-try.--ConflictError.-tp26532984p26534826.html
Sent from the Zope - ZODB-Dev mailing list archive at Nabble.com.



More information about the ZODB-Dev mailing list