[Zodb-checkins] CVS: Packages/ZODB/tests - MTStorage.py:1.10.2.2

Tim Peters tim.one at comcast.net
Mon Apr 4 22:26:22 EDT 2005


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

Modified Files:
      Tag: Zope-2_7-branch
	MTStorage.py 
Log Message:
The various flavors of the ``check2ZODBThreads`` and ``check7ZODBThreads``
tests are much less likely to suffer sproadic failures now.


=== Packages/ZODB/tests/MTStorage.py 1.10.2.1 => 1.10.2.2 ===
--- Packages/ZODB/tests/MTStorage.py:1.10.2.1	Wed Sep  3 16:04:26 2003
+++ Packages/ZODB/tests/MTStorage.py	Mon Apr  4 22:26:21 2005
@@ -79,23 +79,33 @@
         get_transaction().commit()
         time.sleep(self.delay)
 
+    # Return a new PersistentMapping, and store it on the root object under
+    # the name (.getName()) of the current thread.
     def get_thread_dict(self, root):
+        # This is vicious:  multiple threads are slamming changes into the
+        # root object, then trying to read the root object, simultaneously
+        # and without any coordination.  Conflict errors are rampant.  It
+        # used to go around at most 10 times, but that fairly often failed
+        # to make progress in the 7-thread tests on some test boxes.  Going
+        # around (at most) 1000 times was enough so that a 100-thread test
+        # reliably passed on Tim's hyperthreaded WinXP box (but at the
+        # original 10 retries, the same test reliably failed with 15 threads).
         name = self.getName()
-        # arbitrarily limit to 10 re-tries
-        for i in range(10):
+        MAXRETRIES = 1000
+
+        for i in range(MAXRETRIES):
             try:
-                m = PersistentMapping()
-                root[name] = m
+                root[name] = PersistentMapping()
                 get_transaction().commit()
                 break
-            except ConflictError, err:
-                get_transaction().abort()
+            except ConflictError:
                 root._p_jar.sync()
-        for i in range(10):
+
+        for i in range(MAXRETRIES):
             try:
                 return root.get(name)
             except ConflictError:
-                get_transaction().abort()
+                root._p_jar.sync()
 
 class StorageClientThread(TestThread):
 



More information about the Zodb-checkins mailing list