[Zodb-checkins] CVS: ZODB3/ZEO - StorageServer.py:1.74.2.3.2.1

Jeremy Hylton jeremy@zope.com
Thu, 31 Oct 2002 16:02:19 -0500


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

Modified Files:
      Tag: ZODB3-deadlock-debug-branch
	StorageServer.py 
Log Message:
Never use the ImmediateCommitStrategy in tpc_begin().

This is the next step in the deadlock fix, thanks to Guido.  No client
will ever get the commit lock during the tpc_begin().  In tests
designed to provoke deadlock as quickly as possible, this increases
the time until deadlock by roughly 5x.

The changes are the minimum necessary to make the server behaver as
intended.  There is now a fair amount of dead code that could be
deleted, and there is no longer a need for the strategy pattern
because there is only one strategy.  All these changes can be made
later.


=== ZODB3/ZEO/StorageServer.py 1.74.2.3 => 1.74.2.3.2.1 ===
--- ZODB3/ZEO/StorageServer.py:1.74.2.3	Wed Oct 30 16:42:10 2002
+++ ZODB3/ZEO/StorageServer.py	Thu Oct 31 16:02:18 2002
@@ -395,13 +395,8 @@
                                               " requests from one client.")
 
         # (This doesn't require a lock because we're using asyncore)
-        if self.storage._transaction is None:
-            self.strategy = self.ImmediateCommitStrategyClass(self.storage,
-                                                              self.client)
-            self.timeout.begin()
-        else:
-            self.strategy = self.DelayedCommitStrategyClass(self.storage,
-                                                            self.wait)
+        self.strategy = self.DelayedCommitStrategyClass(self.storage,
+                                                        self.wait)
 
         t = Transaction()
         t.id = id
@@ -482,8 +477,10 @@
                      "Clients waiting: %d." % len(self.storage._waiting))
             return d
         else:
-            self.restart()
-            return None
+            return self.restart()
+
+    def dontwait(self):
+        return self.restart()
 
     def handle_waiting(self):
         while self.storage._waiting:
@@ -518,6 +515,8 @@
         resp = old_strategy.restart(self.strategy)
         if delay is not None:
             delay.reply(resp)
+        else:
+            return resp
 
 # A ZEOStorage instance can use different strategies to commit a
 # transaction.  The current implementation uses different strategies
@@ -783,6 +782,7 @@
         self._conn = None
 
     def run(self):
+        log("TimeoutThread created", zLOG.BLATHER)
         timeout = self.TIMEOUT
         while self._conn is not None:
             time.sleep(timeout)