[ZODB-Dev] zeo and zodb : syncing or reconnect which is best?
Jon Dyte
jon@totient.demon.co.uk
Wed, 13 Mar 2002 21:59:08 +0000 (GMT)
Hi
I'm been experimenting with a zodb storage server and
two storage clients and I'm curious to know what the best
way to keep the data in the clients in sync is.
scenario based on the docs:
1) start the zss
/sw/StandaloneZODB/ZEO/start.py -D -p 12345 -h ubiq jj
2) start client a
>>> import ZEO.ClientStorage
>>> st = ZEO.ClientStorage.ClientStorage(('ubiq',12345))
>>> st
<ClientStorage instance at 81351b0>
>>> from ZODB import DB
>>> db = DB(st)
>>> conn = db.open()
>>> conn
<ZODB.Connection.Connection instance at 0x819287c>
>>> root = conn.root()
>>> root
{}
>>> u = User.User()
>>> root['list'] = ['a','b','c']
>>> get_transaction().commit()
>>> root
{'list': ['a', 'b', 'c']}
3) start client b
>>> from ZEO import ClientStorage
>>> from ZODB import DB
>>> import ZEO.ClientStorage
>>> st = ZEO.ClientStorage.ClientStorage(('ubiq',12345))
>>> st
<ClientStorage instance at 81533b8>
>>> db = DB(st)
>>> conn = db.open()
>>> root = conn.root()
>>> root
{}
Now if in client b I attempt to add to the root, I may get a
ConflictError exception and according to amk's documentation/example
you just pause a bit and then try again, normally in a while loop.
as this is interactive, I just wait.
>>> root['list2'] = ['e','f','g']
>>> root['list2']
['e', 'f', 'g']
>>> get_transaction().commit()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/sw/release/python212/lib/python2.1/site-packages/ZODB/Transaction.py", line 238, in commit
j.commit(o,self)
File "/sw/release/python212/lib/python2.1/site-packages/ZODB/Connection.py", line 252, in commit
raise ConflictError(object=object)
ZODB.POSException.ConflictError: database conflict error (oid 0000000000000000, class Persistence.PersistentMapping)
wait a while
>>> get_transaction().commit()
>>> root
{'list2': ['e', 'f', 'g'], 'list': ['a', 'b', 'c']}
>>>
However back in client A I cannot see list2 in root
unless I issue a sync on the connection?
>>> root
{'list': ['a', 'b', 'c']}
>>> conn.sync()
>>> root
{'list2': ['e', 'f', 'g'], 'list': ['a', 'b', 'c']}
When running Zope with zeo, how is the consistency ensured?
Does the zope client storage side, continually reconnect per request
to the storage server, or does it keep issuing sync requests.
What happens to the client cache every time you connect?
Connecting everytime, seems to make this problem go away, but I'm
not sure that's the intended solution?
Thanks
Jon