[Zodb-checkins] CVS: Packages/ZEO - ClientStorage.py:1.26.4.18 TransactionBuffer.py:1.1.2.2

jeremy@digicool.com jeremy@digicool.com
Wed, 2 May 2001 23:10:41 -0400 (EDT)


Update of /cvs-repository/Packages/ZEO
In directory korak:/tmp/cvs-serv15940

Modified Files:
      Tag: ZEO-ZRPC-Dev
	ClientStorage.py TransactionBuffer.py 
Log Message:
Quick fix for cache synchronization bug.

Add the invalidation messages to the transaction buffer.  They never
have a pickle, so the invalidation messages are buffered with the
pickle set to None.  (pickles must be strings, too.)

Do the invalidation after the server returns from tpc_finish().

There may still be some synchronization issues here, but I think they
are less significant.  If a load is performed after the server does
tpc_finish() but before the invalidation, it will contain valid data.
The invalidation will delete it unnecessarily, but will not introduce
an inconsistency.

XXX Still not sure if undo() should behave differently -- probably not
since the undo() isn't part of a transaction.



--- Updated File ClientStorage.py in package Packages/ZEO --
--- ClientStorage.py	2001/05/02 20:44:20	1.26.4.17
+++ ClientStorage.py	2001/05/03 03:10:37	1.26.4.18
@@ -317,7 +317,7 @@
                           POSException.StorageTransactionError)
         oids = self._server.abortVersion(src, self._serial)
         for oid in oids:
-            self._cache.invalidate(oid, src)
+            self._tbuf.invalidate(oid, src)
         return oids
 
     def close(self):
@@ -333,11 +333,11 @@
         if dest:
             # just invalidate our version data
             for oid in oids:
-                self._cache.invalidate(oid, src)
+                self._tbuf.invalidate(oid, src)
         else:
             # dest is '', so invalidate version and non-version
             for oid in oids:
-                self._cache.invalidate(oid, dest)
+                self._tbuf.invalidate(oid, dest)
         return oids
 
     def history(self, oid, version, length=1):
@@ -474,12 +474,11 @@
             if t is None:
                 break
             oid, v, p = t
-            s = self._seriald[oid]
-            if type(s) != StringType:
-                log2(INFO, "bad serialno: %s for %s" % \
-                    (repr(s), repr(oid)))
-            assert type(s) == StringType, "bad serialno: %s" % repr(s)
-            if s == ResolvedSerial:
+            if p is None: # an invalidation 
+                s = None
+            else:
+                s = self._seriald[oid]
+            if s == ResolvedSerial or s is None:
                 self._cache.invalidate(oid, v)
             else:
                 self._cache.update(oid, s, v, p)
@@ -493,10 +492,11 @@
         self._check_trans(trans, POSException.StorageTransactionError)
         oids = self._server.transactionalUndo(trans_id, self._serial)
         for oid in oids:
-            self._cache.invalidate(oid, '')
+            self._tbuf.invalidate(oid, '')
         return oids
 
     def undo(self, transaction_id):
+        # XXX what are the sync issues here?
         oids = self._server.undo(transaction_id)
         for oid in oids:
             self._cache.invalidate(oid, '')                

--- Updated File TransactionBuffer.py in package Packages/ZEO --
--- TransactionBuffer.py	2001/04/02 23:16:12	1.1.2.1
+++ TransactionBuffer.py	2001/05/03 03:10:37	1.1.2.2
@@ -28,6 +28,10 @@
         if version:
             self.size = self.size + len(version) + 4
 
+    def invalidate(self, oid, version):
+        marshal.dump((oid, version, None), self.file)
+        self.count = self.count + 1
+
     def clear(self):
         """Mark the buffer as empty"""
         self.file.seek(0)