[CalendarServer-changes] [9966] CalendarServer/branches/users/glyph/always-abort-txn-on-error

source_changes at macosforge.org source_changes at macosforge.org
Mon Oct 22 16:09:17 PDT 2012


Revision: 9966
          http://trac.calendarserver.org//changeset/9966
Author:   glyph at apple.com
Date:     2012-10-22 16:09:17 -0700 (Mon, 22 Oct 2012)
Log Message:
-----------
Lots of debug prints, make the unit test pass.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/always-abort-txn-on-error/txdav/common/datastore/sql.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/always-abort-txn-on-error/

Modified: CalendarServer/branches/users/glyph/always-abort-txn-on-error/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/always-abort-txn-on-error/txdav/common/datastore/sql.py	2012-10-22 23:09:17 UTC (rev 9965)
+++ CalendarServer/branches/users/glyph/always-abort-txn-on-error/txdav/common/datastore/sql.py	2012-10-22 23:09:17 UTC (rev 9966)
@@ -751,16 +751,30 @@
         block = self._sqlTxn.commandBlock()
         sp = self._savepoint()
         failuresToMaybeLog = []
+        def end():
+            block.end()
+            for f in failuresToMaybeLog:
+                # TODO: direct tests, to make sure error logging
+                # happens correctly in all cases.
+                log.err(f)
+            print("AllRetriesFailed")
+            raise AllRetriesFailed()
         triesLeft = retries
         try:
             while True:
+                print("Acquiring...")
                 yield sp.acquire(block)
+                print 'Acquisition!'
                 try:
+                    print 'thunk...'
                     result = yield thunk(block)
                 except:
+                    f = Failure()
                     if not failureOK:
-                        failuresToMaybeLog.append(Failure())
+                        failuresToMaybeLog.append(f)
+                    print("rolling back..." + repr(f))
                     yield sp.rollback(block)
+                    print("rolled back.")
                     if triesLeft:
                         triesLeft -= 1
                         # Important to get the new block before the old one has
@@ -769,19 +783,17 @@
                         # they actually get done, even if they didn't actually
                         # block or yield to wait for them!  (c.f. property
                         # store writes.)
+                        print("retrying.")
                         newBlock = self._sqlTxn.commandBlock()
                         block.end()
                         block = newBlock
                         sp = self._savepoint()
                     else:
-                        block.end()
-                        for f in failuresToMaybeLog:
-                            # TODO: direct tests, to make sure error logging
-                            # happens correctly in all cases.
-                            log.err(f)
-                        raise AllRetriesFailed()
+                        end()
                 else:
+                    print 'thunk OK', repr(result)
                     yield sp.release(block)
+                    print 'released'
                     block.end()
                     returnValue(result)
         except AlreadyFinishedError:
@@ -790,9 +802,10 @@
             # and only that case - acquire() or release() or commandBlock() may
             # raise an AlreadyFinishedError (either synchronously, or in the
             # case of the first two, possibly asynchronously as well).  We can
-            # safely ignore this, because it can't have any real effect; our
-            # caller shouldn't be paying attention anyway.
-            block.end()
+            # safely ignore this error, because it can't have any effect on what
+            # gets written; our caller will just get told that it failed in a
+            # way they have to be prepared for anyway.
+            end()
 
 
     @inlineCallbacks
@@ -1688,6 +1701,7 @@
 
         @inlineCallbacks
         def _bumpModified(subtxn):
+            print("inner bumpModified")
             yield self._lockLastModifiedQuery.on(subtxn, resourceID=self._resourceID)
             result = (yield self._changeLastModifiedQuery.on(subtxn, resourceID=self._resourceID))
             returnValue(result)
@@ -3432,8 +3446,11 @@
 
         @inlineCallbacks
         def _bumpModified(subtxn):
+            print("1! bumpModified... " + repr(self.name()))
             yield self._lockLastModifiedQuery.on(subtxn, resourceID=self._resourceID)
+            print("2! locked")
             result = (yield self._changeLastModifiedQuery.on(subtxn, resourceID=self._resourceID))
+            print("3! OK changed: %r" % (result,))
             returnValue(result)
 
         try:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121022/24342f19/attachment-0001.html>


More information about the calendarserver-changes mailing list