[Zope-ZEO] Cache invalidation & ZEO

Andrew Kuchling akuchlin@mems-exchange.org
Wed, 04 Oct 2000 15:53:38 -0400


I'm experimenting with having two processes concurrently connecting to
a ZEO server.  I'm not understanding something about how to invalidate
the cache, because the caching is too aggressive for our purposes.

Consider this transcript.  In process 1 I run:

>>> print udb.sec, udb._p_changed
1 0
>>> udb.sec = 2
>>> print udb.sec, udb._p_changed
1 1
>>> get_transaction().commit()

This assigns a value of 2 to the 'sec' attribute of the udb object,
and commits the change.  However, process 2 doesn't see the update,
despite my trying various things:

>>> print udb.sec, udb._p_changed
1 0
>>> get_transaction().commit()          # Does committing help?
>>> print udb.sec, udb._p_changed       # No
1 0
>>> get_transaction().abort()           # Does aborting help?
>>> print udb.sec, udb._p_changed       # No
1 0
>>> base._connection.invalidate(None)   # Sneakiness to invalidate cache
>>> udb = base.get_user_database()  ; print udb.sec  # Still no help
1

Triggering a conflict does help, though:

>>> udb.foo = 2
>>> get_transaction().commit()
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/www/python/lib/python1.5/site-packages/ZODB/Transaction.py", line 251,
in commit
    j.commit(o,self)
  File "/www/python/lib/python1.5/site-packages/ZODB/Connection.py", line 267, in commit
    if invalid(oid) or invalid(None): raise ConflictError, oid
ZODB.POSException.ConflictError:
>>> udb = base.get_user_database()  ; print udb.sec
2

ConflictErrors therefore trigger some sort of massive invalidation; is
there some published way to achieve similar results without a
ConflictError?

--amk