SVN: ZODB/branches/jim-dev/src/ZEO/ checkpoint

Jim Fulton <[email protected]>
Newsgroups gmane.comp.python.zope.zodb.cvs
Message-ID <[email protected]>
Log message for revision 111916:
  checkpoint

Changed:
  U   ZODB/branches/jim-dev/src/ZEO/StorageServer.py
  U   ZODB/branches/jim-dev/src/ZEO/tests/forker.py
  U   ZODB/branches/jim-dev/src/ZEO/tests/testZEO.py
  U   ZODB/branches/jim-dev/src/ZEO/tests/testZEO2.py
  U   ZODB/branches/jim-dev/src/ZEO/zrpc/connection.py

-=-
Modified: ZODB/branches/jim-dev/src/ZEO/StorageServer.py
===================================================================
--- ZODB/branches/jim-dev/src/ZEO/StorageServer.py	2010-05-04 12:07:03 UTC (rev 111915)
+++ ZODB/branches/jim-dev/src/ZEO/StorageServer.py	2010-05-04 13:43:10 UTC (rev 111916)
@@ -447,16 +447,19 @@
     def vote(self, tid):
         self._check_tid(tid, exc=StorageTransactionError)
         if self.locked or self.server.already_waiting(self):
-            raise StorageTransactionError('Already voting %s' % self.locked)
+            raise StorageTransactionError(
+                'Already voting (%s)' % (self.locked and 'locked' or 'waiting')
+                )
         return self._try_to_vote()
 
     def _try_to_vote(self, delay=None):
         if self.connection is None:
             return # We're disconnected
-        if self.locked:
-            # as a consequence of the unlocking strategy,
-            # _try_to_vote may be called multiple times.
-            # Once we're locked, we should stop trying. :)
+        if delay is not None and delay.sent:
+            # as a consequence of the unlocking strategy, _try_to_vote
+            # may be called multiple times for delayed
+            # transactions. The first call will mark the delay as
+            # sent. We should skip if the delay was already sent.
             return
         self.locked, delay = self.server.lock_storage(self, delay)
         if self.locked:
@@ -504,6 +507,7 @@
                     delay.reply(None)
                 else:
                     return None
+
         else:
             return delay
 
@@ -1170,10 +1174,13 @@
             if storage_id in self._commit_locks:
                 # The lock is held by another zeostore
 
-                assert self._commit_locks[storage_id] is not zeostore
+                assert self._commit_locks[storage_id] is not zeostore, (
+                    storage_id, delay)
 
                 if delay is None:
                     # New request, queue it
+                    assert not [i for i in waiting if i[0] is zeostore
+                                ], "already waiting"
                     delay = Delay()
                     waiting.append((zeostore, delay))
                     zeostore.log("(%r) queue lock: transactions waiting: %s"
@@ -1186,7 +1193,7 @@
                 self._commit_locks[storage_id] = zeostore
                 self.timeouts[storage_id].begin(zeostore)
                 self.stats[storage_id].lock_time = time.time()
-                if delay:
+                if delay is not None:
                     # we were waiting, stop
                     waiting[:] = [i for i in waiting if i[0] is not zeostore]
                 zeostore.log("(%r) lock: transactions waiting: %s"
@@ -1206,6 +1213,8 @@
             callbacks = waiting[:]
 
         if callbacks:
+            assert not [i for i in waiting if i[0] is zeostore
+                        ], "waiting while unlocking"
             zeostore.log("(%r) unlock: transactions waiting: %s"
                          % (storage_id, len(callbacks)),
                          _level_for_waiting(callbacks)
@@ -1219,6 +1228,7 @@
                 except Exception:
                     logger.exception("Calling unlock callback")
 
+
     def stop_waiting(self, zeostore):
         storage_id = zeostore.storage_id
         waiting = self._waiting[storage_id]

Modified: ZODB/branches/jim-dev/src/ZEO/tests/forker.py
===================================================================
--- ZODB/branches/jim-dev/src/ZEO/tests/forker.py	2010-05-04 12:07:03 UTC (rev 111915)
+++ ZODB/branches/jim-dev/src/ZEO/tests/forker.py	2010-05-04 13:43:10 UTC (rev 111916)
@@ -91,7 +91,7 @@
 
 def start_zeo_server(storage_conf=None, zeo_conf=None, port=None, keep=False,
                      path='Data.fs', protocol=None, blob_dir=None,
-                     suicide=True, debug=False):
+                     suicide=True, debug=True):
     """Start a ZEO server in a separate process.
 
     Takes two positional arguments a string containing the storage conf

Modified: ZODB/branches/jim-dev/src/ZEO/tests/testZEO.py
===================================================================
--- ZODB/branches/jim-dev/src/ZEO/tests/testZEO.py	2010-05-04 12:07:03 UTC (rev 111915)
+++ ZODB/branches/jim-dev/src/ZEO/tests/testZEO.py	2010-05-04 13:43:10 UTC (rev 111916)
@@ -1219,7 +1219,7 @@
     ------
     --T INFO ZEO.runzeo () opening storage '1' using FileStorage
     ------
-    --T INFO ZEO.StorageServer () StorageServer created RW with storages 1RWt
+    --T INFO ZEO.StorageServer StorageServer created RW with storages 1RWt
     ------
     --T INFO ZEO.zrpc () listening on ...
     ------

Modified: ZODB/branches/jim-dev/src/ZEO/tests/testZEO2.py
===================================================================
--- ZODB/branches/jim-dev/src/ZEO/tests/testZEO2.py	2010-05-04 12:07:03 UTC (rev 111915)
+++ ZODB/branches/jim-dev/src/ZEO/tests/testZEO2.py	2010-05-04 13:43:10 UTC (rev 111916)
@@ -271,7 +271,7 @@
     >>> zs2.vote(tid2)
     Traceback (most recent call last):
     ...
-    StorageTransactionError: Already voting
+    StorageTransactionError: Already voting (locked)
 
     >>> tid1 = start_trans(zs1)
     >>> delay = zs1.vote(tid1)
@@ -283,7 +283,7 @@
     >>> zs1.vote(tid1)
     Traceback (most recent call last):
     ...
-    StorageTransactionError: Already voting
+    StorageTransactionError: Already voting (waiting)
 
 Note that the locking activity is logged at debug level to avoid
 cluttering log files, however, as the number of waiting votes

Modified: ZODB/branches/jim-dev/src/ZEO/zrpc/connection.py
===================================================================
--- ZODB/branches/jim-dev/src/ZEO/zrpc/connection.py	2010-05-04 12:07:03 UTC (rev 111915)
+++ ZODB/branches/jim-dev/src/ZEO/zrpc/connection.py	2010-05-04 13:43:10 UTC (rev 111916)
@@ -44,17 +44,25 @@
     the mainloop from sending a response.
     """
 
+    msgid = conn = sent = None
+
     def set_sender(self, msgid, conn):
         self.msgid = msgid
         self.conn = conn
 
     def reply(self, obj):
+        self.sent = 'reply'
         self.conn.send_reply(self.msgid, obj)
 
     def error(self, exc_info):
+        self.sent = 'error'
         log("Error raised in delayed method", logging.ERROR, exc_info=True)
         self.conn.return_error(self.msgid, *exc_info[:2])
 
+    def __repr__(self):
+        return "%s[%s, %r, %r, %r]" % (
+            self.__class__.__name__, id(self), self.msgid, self.conn, self.sent)
+
 class Result(Delay):
 
     def __init__(self, *args):
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.