[Zodb-checkins] CVS: ZODB3/ZEO - StorageServer.py:1.101.2.3
ServerStub.py:1.17.2.3 ClientStorage.py:1.110.2.5
Jeremy Hylton
cvs-admin at zope.org
Wed Nov 12 17:24:30 EST 2003
Update of /cvs-repository/ZODB3/ZEO
In directory cvs.zope.org:/tmp/cvs-serv4299/ZEO
Modified Files:
Tag: ZODB3-mvcc-2-branch
StorageServer.py ServerStub.py ClientStorage.py
Log Message:
Flesh out lots of mvcc support in ZEO.
Add loadEx() and loadNonCurrent() implementations to client and
server.
Track changes to version and undo APIs that now return a tid in
additions to a list of oids.
Add bogus filter support to client's history() along with a warning
that is issued whenever filter is passed.
=== ZODB3/ZEO/StorageServer.py 1.101.2.2 => 1.101.2.3 ===
--- ZODB3/ZEO/StorageServer.py:1.101.2.2 Wed Nov 5 23:37:09 2003
+++ ZODB3/ZEO/StorageServer.py Wed Nov 12 17:24:25 2003
@@ -241,6 +241,10 @@
self.stats.loads += 1
return self.storage.loadEx(oid, version)
+ def loadNonCurrent(self, oid, tid):
+ self.stats.loads += 1
+ return self.storage.loadNonCurrent(oid, tid)
+
def zeoLoad(self, oid):
self.stats.loads += 1
v = self.storage.modifiedInVersion(oid)
@@ -539,25 +543,25 @@
return self.storage.tpc_vote(self.transaction)
def _abortVersion(self, src):
- oids = self.storage.abortVersion(src, self.transaction)
+ tid, oids = self.storage.abortVersion(src, self.transaction)
inv = [(oid, src) for oid in oids]
self.invalidated.extend(inv)
- return oids
+ return tid, oids
def _commitVersion(self, src, dest):
- oids = self.storage.commitVersion(src, dest, self.transaction)
+ tid, oids = self.storage.commitVersion(src, dest, self.transaction)
inv = [(oid, dest) for oid in oids]
self.invalidated.extend(inv)
if dest:
inv = [(oid, src) for oid in oids]
self.invalidated.extend(inv)
- return oids
+ return tid, oids
def _transactionalUndo(self, trans_id):
- oids = self.storage.transactionalUndo(trans_id, self.transaction)
+ tid, oids = self.storage.transactionalUndo(trans_id, self.transaction)
inv = [(oid, None) for oid in oids]
self.invalidated.extend(inv)
- return oids
+ return tid, oids
# When a delayed transaction is restarted, the dance is
# complicated. The restart occurs when one ZEOStorage instance
=== ZODB3/ZEO/ServerStub.py 1.17.2.2 => 1.17.2.3 ===
--- ZODB3/ZEO/ServerStub.py:1.17.2.2 Wed Nov 5 23:37:09 2003
+++ ZODB3/ZEO/ServerStub.py Wed Nov 12 17:24:26 2003
@@ -185,6 +185,19 @@
return self.rpc.call("loadEx", oid, version)
##
+ # Return non-current data along with transaction ids that identify
+ # the lifetime of the specific revision.
+ # @param oid object id
+ # @param tid a transaction id that provides an upper bound on
+ # the lifetime of the revision. That is, loadNonCurrent
+ # returns the revision that was current before tid committed.
+ # @defreturn 4-tuple
+ # @return data, serial numbr, start transaction id, end transaction id
+
+ def loadNonCurrent(self, oid, tid):
+ return self.rpc.call("loadNonCurrent", oid, tid)
+
+ ##
# Storage new revision of oid.
# @param oid object id
# @param serial serial number that this transaction read
=== ZODB3/ZEO/ClientStorage.py 1.110.2.4 => 1.110.2.5 ===
--- ZODB3/ZEO/ClientStorage.py:1.110.2.4 Tue Nov 11 17:16:12 2003
+++ ZODB3/ZEO/ClientStorage.py Wed Nov 12 17:24:26 2003
@@ -672,7 +672,7 @@
def abortVersion(self, version, transaction):
"""Storage API: clear any changes made by the given version."""
self._check_trans(transaction)
- oids = self._server.abortVersion(version, self._serial)
+ tid, oids = self._server.abortVersion(version, self._serial)
# When a version aborts, invalidate the version and
# non-version data. The non-version data should still be
# valid, but older versions of ZODB will change the
@@ -684,12 +684,13 @@
# we could just invalidate the version data.
for oid in oids:
self._tbuf.invalidate(oid, '')
- return oids
+ return tid, oids
def commitVersion(self, source, destination, transaction):
"""Storage API: commit the source version in the destination."""
self._check_trans(transaction)
- oids = self._server.commitVersion(source, destination, self._serial)
+ tid, oids = self._server.commitVersion(source, destination,
+ self._serial)
if destination:
# just invalidate our version data
for oid in oids:
@@ -698,14 +699,17 @@
# destination is '', so invalidate version and non-version
for oid in oids:
self._tbuf.invalidate(oid, destination)
- return oids
+ return tid, oids
- def history(self, oid, version, length=1):
+ def history(self, oid, version, length=1, filter=None):
"""Storage API: return a sequence of HistoryEntry objects.
This does not support the optional filter argument defined by
the Storage API.
"""
+ if filter is not None:
+ log2(WARNING, "filter argument to history() ignored")
+ # XXX should I run filter on the results?
return self._server.history(oid, version, length)
def getSerial(self, oid):
@@ -723,11 +727,14 @@
specified by the given object id and version, if they exist;
otherwise a KeyError is raised.
"""
+ return self.loadEx(oid, version)[:2]
+
+ def loadEx(self, oid, version):
self._lock.acquire() # for atomic processing of invalidations
try:
- pair = self._cache.load(oid, version)
- if pair:
- return pair
+ triple = self._cache.load(oid, version)
+ if triple:
+ return triple
finally:
self._lock.release()
@@ -755,7 +762,43 @@
finally:
self._load_lock.release()
- return data, serial
+ return data, serial, tid
+
+ def loadNonCurrent(self, oid, tid):
+ self._lock.acquire()
+ try:
+ t = self._cache.loadNonCurrent(oid, tid)
+ if t is not None:
+ return t
+ finally:
+ self._lock.release()
+
+ t = self._server.loadNonCurrent(oid, tid)
+ if t is None:
+ return None
+ data, serial, start, end = t
+ if end is None:
+ # This method should not be used to get current data. It
+ # doesn't use the _load_lock, so it is possble to overlap
+ # this load with an invalidation for the same object.
+
+ # XXX If we call again, we're guaranteed to get the
+ # post-invalidation data. But if the data is still
+ # current, we'll still get end == None.
+
+ # Maybe the best thing to do is to re-run the test with
+ # the load lock in the case. That's slow performance, but
+ # I don't think real application code will ever care about
+ # it.
+
+ return data, serial, start, end
+ self._lock.acquire()
+ try:
+ self._cache.store(oid, "", serial, start, end, data)
+ finally:
+ self._lock.release()
+
+ return data, serial, start, end
def modifiedInVersion(self, oid):
"""Storage API: return the version, if any, that modfied an object.
@@ -975,10 +1018,10 @@
a storage.
"""
self._check_trans(trans)
- oids = self._server.transactionalUndo(trans_id, self._serial)
+ tid, oids = self._server.transactionalUndo(trans_id, self._serial)
for oid in oids:
self._tbuf.invalidate(oid, '')
- return oids
+ return tid, oids
def undoInfo(self, first=0, last=-20, specification=None):
"""Storage API: return undo information."""
More information about the Zodb-checkins
mailing list