[Zope-Checkins] CVS: ZODB3/ZEO - cache.py:1.1.2.6
Jeremy Hylton
cvs-admin at zope.org
Thu Nov 13 13:45:29 EST 2003
Update of /cvs-repository/ZODB3/ZEO
In directory cvs.zope.org:/tmp/cvs-serv11003/ZEO
Modified Files:
Tag: ZODB3-mvcc-2-branch
cache.py
Log Message:
Fix bug in cache's version handling.
It returned version data even if requesting data for a different
version that the stored data used.
=== ZODB3/ZEO/cache.py 1.1.2.5 => 1.1.2.6 ===
--- ZODB3/ZEO/cache.py:1.1.2.5 Wed Nov 12 17:20:37 2003
+++ ZODB3/ZEO/cache.py Thu Nov 13 13:44:58 2003
@@ -91,9 +91,8 @@
# Maps oid to list of (start_tid, end_tid) pairs in sorted order.
# Used to find matching key for load of non-current data.
self.noncurrent = {}
- # XXX I think oid, version can map to oid, tid without confusion.
- # A transaction can write version data or non-version data,
- # but not both.
+ # Map oid to version, tid pair. If there is no entry, the object
+ # is not modified in a version.
self.version = {}
# A double-linked list is used to manage the cache. It makes
@@ -117,7 +116,7 @@
break
oid = o.key[0]
if o.version:
- self.version[oid] = o.start_tid
+ self.version[oid] = o.version, o.start_tid
elif o.end_tid is None:
self.current[oid] = o.start_tid
else:
@@ -169,7 +168,13 @@
# @defreturn 3-tuple: (string, string, string)
def load(self, oid, version=""):
- tid = version and self.version.get(oid) or self.current.get(oid)
+ tid = None
+ if version:
+ p = self.version.get(oid)
+ if p is not None and p[0] == version:
+ tid = p[1]
+ if tid is None:
+ tid = self.current.get(oid)
if tid is None:
return None
o = self.dll.access((oid, tid))
@@ -210,11 +215,11 @@
# @defreturn string or None
def modifiedInVersion(self, oid):
- tid = self.version.get(oid)
- if tid is None:
+ p = self.version.get(oid)
+ if p is None:
return None
- o = self.dll.access((oid, tid))
- return o.version
+ version, tid = p
+ return version
##
# Store a new data record in the cache.
@@ -235,7 +240,7 @@
if version:
if end_tid is not None:
raise ValueError("cache only stores current version data")
- self.version[oid] = start_tid
+ self.version[oid] = version, start_tid
else:
if end_tid is None:
if oid in self.current:
@@ -299,10 +304,11 @@
else:
del self.current[oid]
else:
- # XXX haven't handled non-current
+ # XXX Although we use bisect to keep the list sorted,
+ # we never expect the list to be very long. So the
+ # brute force approach should normally be fine.
L = self.noncurrent[oid]
- i = bisect.bisect_left((o.start_end, o.end_tid))
- print L, i
+ L.remove((o.start_tid, o.end_tid))
##
# An object that's part of a headed, circular, doubly-linked list.
More information about the Zope-Checkins
mailing list