[Zope-ZEO] Cache invalidation & ZEO

Jim Fulton jim@digicool.com
Sat, 07 Oct 2000 13:17:42 -0400


Andrew Kuchling wrote:
> 
> 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?

This is only an issue when running "synchronously", out of the control of
an asyncore main loop. It arises
from the fact that there is no asyncore main loop running and,
therefore, no way to get asynchronous cache invalidation
messages. We don't get communication from the server unless
we contact it for some other reason, such as a read or write.

I'm going to need to add some additional API to allow this.

In the mean time, to hack my way around this, I make commit
meaningless modification to force an update.

Jim


--
Jim Fulton           mailto:jim@digicool.com
Technical Director   (888) 344-4332              Python Powered!
Digital Creations    http://www.digicool.com     http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.