[Zodb-checkins] CVS: StandaloneZODB/ZODB - Transaction.py:1.35

Jeremy Hylton jeremy@zope.com
Fri, 12 Apr 2002 14:29:16 -0400


Update of /cvs-repository/StandaloneZODB/ZODB
In directory cvs.zope.org:/tmp/cvs-serv23104

Modified Files:
	Transaction.py 
Log Message:
Wrap abort_sub() call in try/except that logs exception and continues.

This fixes the transient failure in testExceptionInSubAbortSub() and
is presumed to be correct, too.  The old code had the comment:
    # This should never fail
but did not to guarantee that it never failed.  I'm assuming that the
write fix is to log the error and ignore it, because that's what the
call to tpc_abort() immediately above does.

XXX commit() is a really long method.  It would be nice to break it up
into easier-to-understand chunks.


=== StandaloneZODB/ZODB/Transaction.py 1.34 => 1.35 ===
                     # Someone finished, so don't allow any more
                     # work without at least a restart!
-                    hosed=1
+                    hosed = 1
                     LOG('ZODB', PANIC,
                         "A storage error occurred in the last phase of a "
                         "two-phase commit.  This shouldn\'t happen. "
@@ -287,7 +287,7 @@
                     raise
                 
             except:
-                t,v,tb=sys.exc_info()
+                t, v, tb = sys.exc_info()
 
                 # Ugh, we got an got an error during commit, so we
                 # have to clean up.
@@ -295,32 +295,42 @@
                 # First, we have to abort any uncommitted objects.
                 for o in objects[ncommitted:]:
                     try:
-                        j=getattr(o, '_p_jar', o)
-                        if j is not None: j.abort(o, self)
-                    except: pass
+                        j = getattr(o, '_p_jar', o)
+                        if j is not None:
+                            j.abort(o, self)
+                    except:
+                        pass
 
                 # Then, we unwind TPC for the jars that began it.
                 if jarsv is None:
                     jarsv = jars.values()
                 for j in jarsv:
-                    try: j.tpc_abort(self) # This should never fail
+                    try:
+                        j.tpc_abort(self) # This should never fail
                     except:     
                         LOG('ZODB', ERROR,
                             "A storage error occured during object abort "
-                            "This shouldn\'t happen. ",
+                            "This shouldn't happen. ",
                             error=sys.exc_info())
                 
                 # Ugh, we need to abort work done in sub-transactions.
                 while subjars:
-                    j=subjars.pop()
-                    j.abort_sub(self) # This should never fail
+                    j = subjars.pop()
+                    try:
+                        j.abort_sub(self) # This should never fail
+                    except:
+                        LOG('ZODB', ERROR,
+                            "A storage error occured during sub-transaction "
+                            "object abort.  This shouldn't happen.",
+                            error=sys.exc_info())
 
-                raise t,v,tb
+                raise t, v, tb
 
         finally:
-            tb=None
+            tb = None
             del objects[:] # clear registered
-            if not subtransaction and self._id is not None: free_transaction()
+            if not subtransaction and self._id is not None:
+                free_transaction()
 
     def register(self,object):
         'Register the given object for transaction control.'