[Zope-Checkins] CVS: ZODB3/ZEO/tests - ConnectionTests.py:1.4.2.2

Barry Warsaw barry@wooz.org
Mon, 20 Jan 2003 16:01:06 -0500


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

Modified Files:
      Tag: ZODB3-3_1-branch
	ConnectionTests.py 
Log Message:
checkDisconnectionAbort(): Backported from 3.2 trunk, this tests that
a tpc_abort when disconnected from the server, properly cleans up data
structures and does not raise an exception.  This test differs from
the trunk in that Disconnected is used instead of ClientDisconnected,
and there is no _wait() in 3.1 (so we use a dumb 5 second loop).


=== ZODB3/ZEO/tests/ConnectionTests.py 1.4.2.1 => 1.4.2.2 ===
--- ZODB3/ZEO/tests/ConnectionTests.py:1.4.2.1	Thu Oct  3 20:09:05 2002
+++ ZODB3/ZEO/tests/ConnectionTests.py	Mon Jan 20 16:01:03 2003
@@ -23,14 +23,15 @@
 
 import zLOG
 
-from ZEO.ClientStorage import ClientStorage
+from ZEO.ClientStorage import ClientStorage, ClientDisconnected
 from ZEO.Exceptions import Disconnected
 from ZEO.zrpc.marshal import Marshaller
 
-from ZODB.Transaction import get_transaction
+from ZODB.Transaction import get_transaction, Transaction
 from ZODB.POSException import ReadOnlyError
 from ZODB.tests import StorageTestBase
-from ZODB.tests.StorageTestBase import zodb_unpickle, MinPO
+from ZODB.tests.MinPO import MinPO
+from ZODB.tests.StorageTestBase import zodb_pickle, zodb_unpickle
 
 class DummyDB:
     def invalidate(self, *args):
@@ -388,6 +389,47 @@
         self.shutdownServer()
         self._storage = self.openClientStorage('test', 1000, wait=0)
         self.assertRaises(Disconnected, self._storage.load, 'fredwash', '')
+
+    def checkDisconnectedAbort(self):
+        self._storage = self.openClientStorage()
+        self._dostore()
+        oids = [self._storage.new_oid() for i in range(5)]
+        txn = Transaction()
+        self._storage.tpc_begin(txn)
+        for oid in oids:
+            data = zodb_pickle(MinPO(oid))
+            self._storage.store(oid, None, data, '', txn)
+        self.shutdownServer()
+        self.assertRaises(Disconnected, self._storage.tpc_vote, txn)
+        self._storage.tpc_abort(txn)
+        self.startServer(create=0)
+        # Keep trying until we reconnect.  In ZODB 3.2 this is done by calling
+        # _wait() on the storage.
+        for i in range(10):
+            try:
+                self._dostore()
+                break
+            except Disconnected:
+                time.sleep(0.5)
+
+        # This test is supposed to cover the following error, although
+        # I don't have much confidence that it does.  The likely
+        # explanation for the error is that the _tbuf contained
+        # objects that weren't in the _seriald, because the client was
+        # interrupted waiting for tpc_vote() to return.  When the next
+        # transaction committed, it tried to do something with the
+        # bogus _tbuf entries.  The exaplanation is wrong/incomplete,
+        # because tpc_begin() should clear the _tbuf.
+
+        # 2003-01-15T15:44:19 ERROR(200) ZODB A storage error occurred
+        # in the last phase of a two-phase commit.  This shouldn't happen.
+
+        # Traceback (innermost last):
+        # Module ZODB.Transaction, line 359, in _finish_one
+        # Module ZODB.Connection, line 691, in tpc_finish
+        # Module ZEO.ClientStorage, line 679, in tpc_finish
+        # Module ZEO.ClientStorage, line 709, in _update_cache
+        # KeyError: ...
 
     def checkBasicPersistence(self):
         # Verify cached data persists across client storage instances.