[Zope-Checkins] CVS: ZODB3/ZEO - ClientStorage.py:1.73.2.27

Tim Peters tim.one at comcast.net
Mon Aug 4 19:14:33 EDT 2003


Update of /cvs-repository/ZODB3/ZEO
In directory cvs.zope.org:/tmp/cvs-serv24603/ZEO

Modified Files:
      Tag: ZODB3-3_1-branch
	ClientStorage.py 
Log Message:
Side-porting critical ZEO client fixes from ZODB3-3_1-boston-branch.

+ If a storage times out between the vote and the finish, the ZEO cache
  could get populated with objects that don't make it to the storage
  server.

  A new flag self._midtxn_disconnect gets reset in tpc_begin() and set
  in notifyDisconnected().  If tpc_finish() discovers this flag set, it
  raises a ClientDisconnected error before calling tpc_finish() on the
  server.

+ In tpc_finish() we re-order the calls so that the server's tpc_finish()
  is called (and must succeed) before we update the ZEO client cache.

+ The storage name is now prepended to the sort key, to ensure a
  unique global sort order if storages are named uniquely.

NOTE:  The Berkeley tests are all hosed on Windows in this branch now,
but that was true before this patch.


=== ZODB3/ZEO/ClientStorage.py 1.73.2.26 => 1.73.2.27 ===
--- ZODB3/ZEO/ClientStorage.py:1.73.2.26	Thu Jun 12 16:36:51 2003
+++ ZODB3/ZEO/ClientStorage.py	Mon Aug  4 18:13:58 2003
@@ -226,6 +226,9 @@
         self._conn_is_read_only = 0
         self._storage = storage
         self._read_only_fallback = read_only_fallback
+        # Flag tracking disconnections in the middle of a transaction.  This
+        # is reset in tpc_begin() and set in notifyDisconnected().
+        self._midtxn_disconnect = 0
         # _server_addr is used by sortKey()
         self._server_addr = None
         self._tfile = None
@@ -471,7 +474,7 @@
         if self._server_addr is None:
             raise ClientDisconnected
         else:
-            return self._server_addr
+            return '%s:%s' % (self._storage, self._server_addr)
 
     def verify_cache(self, server):
         """Internal routine called to verify the cache."""
@@ -505,6 +508,7 @@
         self._connection = None
         self._ready.clear()
         self._server = disconnected_stub
+        self._midtxn_disconnect = 1
 
     def __len__(self):
         """Return the size of the storage."""
@@ -731,6 +735,7 @@
         if self._is_read_only:
             raise POSException.ReadOnlyError()
         self._tpc_cond.acquire()
+        self._midtxn_disconnect = 0
         while self._transaction is not None:
             # It is allowable for a client to call two tpc_begins in a
             # row with the same transaction, and the second of these
@@ -804,6 +809,12 @@
             return
         self._load_lock.acquire()
         try:
+            if self._midtxn_disconnect:
+                raise ClientDisconnected(
+                    'Calling tpc_finish() on a disconnected transaction')
+
+            self._server.tpc_finish(self._serial)
+
             self._lock.acquire()  # for atomic processing of invalidations
             try:
                 self._update_cache()
@@ -811,8 +822,6 @@
                     f()
             finally:
                 self._lock.release()
-
-            self._server.tpc_finish(self._serial)
 
             r = self._check_serials()
             assert r is None or len(r) == 0, "unhandled serialnos: %s" % r




More information about the Zope-Checkins mailing list