I'm trying to understand just how ZEO/zodb should work when there are
two connections open to the *same* database at the *same time* and one
connection updates an object in the database. If an object in the
database is modified from one of the connections, that modification is
*not* propogated to the second connection, unless a .sync() is performed
on the connection itself (or the connection is closed/reopened).

Is a sync actually required in a scenario such as this? Does normal
usage of multiple connections to the same database require that a sync
is performed in order to propogate changes between the two (or more)
connections and maintain consistency?

I'm unable to find sufficient documentation regarding this issue, or the
sync method itself (other than sync aborts any open transactions). What
I would like to know is if syncing is the normal procedure for keeping
multiple connections consistent, or I'm simply going about things in the
wrong way.

Below is a summary of python interactive shell commands that will
produce the issue which I'm trying to gather more information on:

This is generally how I connect to the DB
>>> import ZEO, transaction, ZODB
>>> import ZODB.config
>>> import transaction
>>> from persistent.mapping import PersistentMapping
>>> db =
>>> dbConnection = db.open()
>>> root = dbConnection.root()

>>> ZEO.version

Zeo is started like so
/usr/bin/python /usr/bin/runzeo.py -C ~/sandbox/zope/zeo_server.conf

The zeo_client.conf looks like this
    server localhost:8090
    max-disconnect-poll 5

zeo_server.conf looks like this
<filestorage 1>
    path /home/jay/sandbox/zope/test.db2
        path /home/jay/sandbox/zope/zeo.log
        format %(asctime)s %(message)s

The DB was initialized like so (it was initially nonexistant)
>>> t = transaction.begin()
>>> root['Test'] = PersistentMapping()
>>> t.commit()

Now, I connect to the database in two separate python shells.
There are two connections open to the same DB at this point.
I used the above connection method and do this in both shells.
The result is exactly the same...
>>> temp = root['Test']
>>> temp

Now, In the first shell, I do this
>>> t = transaction.begin()
>>> temp.update({1:'testing'})
>>> t.commit()
>>> temp
{1: 'testing'}

In the second, I do this
>>> temp

Note that nothing has been updated into my second connection
to the DB. Now, if I do a sync on the dbConnection....
>>> dbConnection.sync()
>>> temp
{1: 'testing'}

Magic. I now have the updated contents from the Test table
of the database. Is the sync required in order to update 
the second connection, or am I doing something incorrectly?

Thanks for your time, and let me know if you require any additional


For more information about ZODB, see the ZODB Wiki:

ZODB-Dev mailing list  -  ZODB-Dev@zope.org

Reply via email to