[Zodb-checkins] SVN: ZODB/trunk/src/ Bug fixed
Jim Fulton
jim at zope.com
Tue Sep 7 14:44:45 EDT 2010
Log message for revision 116215:
Bug fixed
---------
- Database connections didn't invalidate cache entries when conflict
errors were raised in response to checkCurrentSerialInTransaction
errors. Normally, this shouldn't be a problem, since there should be
pending invalidations for these oids which will cause the object to
be invalidated. There have been issues with ZEO persistent cache
management that have caused out of date data to remain in the cache.
(It's possible that the last of these were addressed in the
3.10.0b5.) Invalidating read data when there is a conflict error
provides some extra insurance.
Changed:
U ZODB/trunk/src/CHANGES.txt
U ZODB/trunk/src/ZODB/Connection.py
U ZODB/trunk/src/ZODB/tests/testConnection.py
-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt 2010-09-07 13:45:36 UTC (rev 116214)
+++ ZODB/trunk/src/CHANGES.txt 2010-09-07 18:44:45 UTC (rev 116215)
@@ -2,6 +2,23 @@
Change History
================
+3.10.0b6 (2010-09-??)
+=====================
+
+Bugs fixed
+----------
+
+- Database connections didn't invalidate cache entries when conflict
+ errors were raised in response to checkCurrentSerialInTransaction
+ errors. Normally, this shouldn't be a problem, since there should be
+ pending invalidations for these oids which will cause the object to
+ be invalidated. There have been issues with ZEO persistent cache
+ management that have caused out of date data to remain in the cache.
+ (It's possible that the last of these were addressed in the
+ 3.10.0b5.) Invalidating read data when there is a conflict error
+ provides some extra insurance.
+
+
3.10.0b5 (2010-09-02)
=====================
Modified: ZODB/trunk/src/ZODB/Connection.py
===================================================================
--- ZODB/trunk/src/ZODB/Connection.py 2010-09-07 13:45:36 UTC (rev 116214)
+++ ZODB/trunk/src/ZODB/Connection.py 2010-09-07 18:44:45 UTC (rev 116215)
@@ -557,8 +557,12 @@
self._commit(transaction)
for oid, serial in self._readCurrent.iteritems():
- self._storage.checkCurrentSerialInTransaction(
- oid, serial, transaction)
+ try:
+ self._storage.checkCurrentSerialInTransaction(
+ oid, serial, transaction)
+ except ConflictError:
+ self._cache.invalidate(oid)
+ raise
def _commit(self, transaction):
"""Commit changes to an object"""
@@ -754,7 +758,13 @@
vote = self._storage.tpc_vote
except AttributeError:
return
- s = vote(transaction)
+ try:
+ s = vote(transaction)
+ except ReadConflictError, v:
+ if v.oid:
+ self._cache.invalidate(v.oid)
+ raise
+
if s:
for oid, serial in s:
self._handle_serial(oid, serial)
Modified: ZODB/trunk/src/ZODB/tests/testConnection.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testConnection.py 2010-09-07 13:45:36 UTC (rev 116214)
+++ ZODB/trunk/src/ZODB/tests/testConnection.py 2010-09-07 18:44:45 UTC (rev 116215)
@@ -680,6 +680,7 @@
If the storage raises a conflict error, it'll be propigated:
+ >>> _ = str(conn.root.a) # do read
>>> bad.add(conn.root.a._p_oid)
>>> conn.readCurrent(conn.root.a)
>>> conn.root.b.x += 1
@@ -690,6 +691,10 @@
>>> transaction.abort()
+The conflict error will cause the affected object to be invalidated:
+
+ >>> conn.root.a._p_changed
+
The storage may raise it later:
>>> def checkCurrentSerialInTransaction(oid, serial, trans):
@@ -709,6 +714,7 @@
It will still be propigated:
+ >>> _ = str(conn.root.a) # do read
>>> conn.readCurrent(conn.root.a)
>>> conn.root.b.x = +1
>>> transaction.commit()
@@ -718,6 +724,10 @@
>>> transaction.abort()
+The conflict error will cause the affected object to be invalidated:
+
+ >>> conn.root.a._p_changed
+
Read checks don't leak accross transactions:
>>> conn.readCurrent(conn.root.a)
More information about the Zodb-checkins
mailing list