[Zodb-checkins] CVS: Packages/ZODB/tests - testZODB.py:1.15.8.7

Tim Peters tim.one at comcast.net
Thu Sep 16 19:56:19 EDT 2004


Update of /cvs-repository/Packages/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv4226/ZODB/tests

Modified Files:
      Tag: Zope-2_7-branch
	testZODB.py 
Log Message:
Connection memory of ReadConflictErrors wasn't cleared by an abort().


=== Packages/ZODB/tests/testZODB.py 1.15.8.6 => 1.15.8.7 ===
--- Packages/ZODB/tests/testZODB.py:1.15.8.6	Tue Aug 31 18:51:34 2004
+++ Packages/ZODB/tests/testZODB.py	Thu Sep 16 19:56:18 2004
@@ -326,6 +326,49 @@
         cn2.getTransaction().commit()
         get_transaction().abort()
 
+    def checkReadConflictErrorClearedDuringAbort(self):
+        # When a transaction is aborted, the "memory" of which
+        # objects were the cause of a ReadConflictError during
+        # that transaction should be cleared.
+        root = self._db.open().root()
+        data = PersistentMapping({'d': 1})
+        root["data"] = data
+        get_transaction().commit()
+
+        # Provoke a ReadConflictError.
+        cn2 = self._db.open()
+        cn2.setLocalTransaction()
+        r2 = cn2.root()
+        data2 = r2["data"]
+
+        data['d'] = 2
+        get_transaction().commit()
+
+        try:
+            data2['d'] = 3
+        except ReadConflictError:
+            pass
+        else:
+            self.fail("No conflict occurred")
+
+        # Explictly abort cn2's transaction.
+        cn2.getTransaction().abort()
+
+        # cn2 should retain no memory of the read conflict after an abort(),
+        # but we had a bug wherein it did.
+        data_conflicts = data._p_jar._conflicts
+        data2_conflicts = data2._p_jar._conflicts
+        self.failIf(data_conflicts)
+        self.failIf(data2_conflicts)  # this used to fail
+
+        # And because of that, we still couldn't commit a change to data2['d']
+        # in the new transaction.
+        cn2.sync()  # process the invalidation for data2['d'] 
+        data2['d'] = 3
+        cn2.getTransaction().commit()  # this used to raise ReadConflictError
+
+        cn2.close()
+
     def checkIndependent(self):
         self.obj = Independent()
         self.readConflict(shouldFail=0)



More information about the Zodb-checkins mailing list