[Zodb-checkins] CVS: ZODB3/ZEO - ClientStorage.py:1.73.2.30

Tim Peters tim.one at comcast.net
Tue Aug 26 14:53:03 EDT 2003


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

Modified Files:
      Tag: ZODB3-3_1-branch
	ClientStorage.py 
Log Message:
ClientStorage.tpc_vote():  Fiddled the exponential backoff strategy:
(1) milder ramp-up; (2) randomized sleep times; (3) don't sleep if,
upon waking up, it's certain to give up.  These are enough so that
checkConcurrentLargeUpdates() using Berkeley on Win2K usually passes
now instead of always failing (before, one or both threads of the
two sharing a connection never managed to add anything to the tree,
doing accidentally synchronized sleeps in the backoff loop).


=== ZODB3/ZEO/ClientStorage.py 1.73.2.29 => 1.73.2.30 ===
--- ZODB3/ZEO/ClientStorage.py:1.73.2.29	Mon Aug 25 23:36:44 2003
+++ ZODB3/ZEO/ClientStorage.py	Tue Aug 26 13:53:02 2003
@@ -725,18 +725,19 @@
 
     def tpc_vote(self, transaction):
         """Storage API: vote on a transaction."""
+        from random import random
         if transaction is not self._transaction:
             return
-        backoff = 0.24
-        attempts = 0
+        max_backoff = 0.5   # seconds
+        total_backoff = 0.0
         while 1:
             if self._server.vote_nb(self._serial) == "VOTE_BACKOFF":
-                time.sleep(backoff)
-                attempts += 1
-                backoff *= 2
-                backoff = min(backoff, 60)
-                if attempts > 70:
+                if total_backoff >= 3600.0: # waited an hour already
                     raise StorageSystemError("Timed out waiting to vote")
+                backoff = random() * max_backoff
+                time.sleep(backoff)
+                total_backoff += backoff
+                max_backoff = min(max_backoff * 1.5, 60)
             else:
                 break
         return self._check_serials()




More information about the Zodb-checkins mailing list