[Zope-dev] ZPatterns: transaction bug

Steve Alexander steve@cat-box.net
Sun, 03 Sep 2000 11:13:44 +0100


While updating a load of DataSkins all together using a ZCatalog, I got
this error:

----
2000-09-03T08:03:13 PANIC(300) ZODB A storage error occurred in the last
phase of a two-phase commit.  This shouldn't happen. The application may
be in a hosed state, so transactions will not be allowed to commit until
the site/storage is reset by a restart. 
Traceback (innermost last):
  File lib/python/ZODB/Transaction.py, line 296, in commit
  File lib/python/Products/ZPatterns/Transactions.py, line 108, in
tpc_finish
  File lib/python/Products/ZPatterns/Transactions.py, line 137, in
end_tran
  File lib/python/Products/ZPatterns/Transactions.py, line 48, in
_unregister
    (Object: ProviderContainer)
KeyError: _v_registered
----

The line from Transactions.py in question is:

    def _unregister(self):
        del self._v_registered

From a little bit of instrumentation, I see that one of my Customizer
instances is getting unregistered twice in a row.

An obvious naive fix is to put the del line in a try-except block, or to
change it to

  if self._v_registered: del self._v_registered


From a lot of instrumenting code, tinkering and reading up on the ZODB
transaction system, I think I've found what the problem is.

The error happens when the ZCatalog attempts to commit a subtransaction.