[Zodb-checkins] SVN: ZODB/trunk/src/ First part of the fix for #181712.

Christian Theune ct at gocept.com
Thu Jan 31 08:21:05 EST 2008


Log message for revision 83332:
  First part of the fix for #181712.
  

Changed:
  U   ZODB/trunk/src/CHANGES.txt
  U   ZODB/trunk/src/ZEO/ClientStorage.py
  U   ZODB/trunk/src/ZEO/tests/testZEO.py

-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt	2008-01-31 13:20:44 UTC (rev 83331)
+++ ZODB/trunk/src/CHANGES.txt	2008-01-31 13:21:04 UTC (rev 83332)
@@ -35,6 +35,9 @@
 Bugs Fixed
 ----------
 
+- Fix for bug #181712: Make ClientStorage update `lastTransaction` directly
+  after connecting to a server, even when no cache verification is necessary.
+
 - Fixed bug in blob filesystem helper: the `isSecure` check was inversed.
 
 - Fixed bug in transaction buffer: a tuple was unpacked incorrectly in

Modified: ZODB/trunk/src/ZEO/ClientStorage.py
===================================================================
--- ZODB/trunk/src/ZEO/ClientStorage.py	2008-01-31 13:20:44 UTC (rev 83331)
+++ ZODB/trunk/src/ZEO/ClientStorage.py	2008-01-31 13:21:04 UTC (rev 83332)
@@ -567,21 +567,22 @@
         The return value (indicating which path we took) is used by
         the test suite.
         """
-
         # If verify_cache() finishes the cache verification process,
         # it should set self._server.  If it goes through full cache
-        # verification, then endVerify() should self._server.
+        # verification, then endVerify() should set self._server.
 
+        ltid = server.lastTransaction()
+
         if not self._cache:
             log2("No verification necessary -- empty cache")
             self._server = server
+            if ltid and ltid != utils.z64:
+                self._cache.setLastTid(ltid)
             self._ready.set()
             return "full verification"
 
-
         last_inval_tid = self._cache.getLastTid()
         if last_inval_tid is not None:
-            ltid = server.lastTransaction()
             if ltid == last_inval_tid:
                 log2("No verification necessary (last_inval_tid up-to-date)")
                 self._server = server

Modified: ZODB/trunk/src/ZEO/tests/testZEO.py
===================================================================
--- ZODB/trunk/src/ZEO/tests/testZEO.py	2008-01-31 13:20:44 UTC (rev 83331)
+++ ZODB/trunk/src/ZEO/tests/testZEO.py	2008-01-31 13:21:04 UTC (rev 83332)
@@ -57,10 +57,12 @@
 
 logger = logging.getLogger('ZEO.tests.testZEO')
 
+
 class DummyDB:
     def invalidate(self, *args):
         pass
 
+
 class OneTimeTests(unittest.TestCase):
 
     def checkZEOVersionNumber(self):
@@ -128,6 +130,23 @@
         finally:
             storage2.close()
 
+    def checkVolatileCacheWithImmediateLastTransaction(self):
+        # Earlier, a ClientStorage would not have the last transaction id
+        # available right after successful connection, this is required now.
+        addr = self._storage._addr
+        storage2 = ClientStorage(addr)
+        self.assert_(storage2.is_connected())
+        self.assertEquals(None, storage2.lastTransaction())
+        storage2.close()
+
+        self._dostore()
+        storage3 = ClientStorage(addr)
+        self.assert_(storage3.is_connected())
+        self.assertEquals(8, len(storage3.lastTransaction()))
+        self.assertNotEquals(ZODB.utils.z64, storage3.lastTransaction())
+        storage3.close()
+
+
 def get_port():
     """Return a port that is not in use.
 
@@ -645,10 +664,10 @@
             ]
         [thread.start() for thread in threads]
         [thread.join() for thread in threads]
-        [self.assertEqual(r, filename) for r in returns]        
+        [self.assertEqual(r, filename) for r in returns]
         check_data(filename)
-        
 
+
 class BlobWritableCacheTests(GenericTests, CommonBlobTests):
 
     def setUp(self):



More information about the Zodb-checkins mailing list