[Zope-dev] ZPatterns transactions bug

Steve Alexander steve@cat-box.net
Sun, 03 Sep 2000 12:53:06 +0100


Here's a trace of all the transaction calls to do with a particular
customizer.

I have instrumented ZPatterns.Transactions.Transactional like this:


    def _register(self):
        if self.id=='customize_items':
            print "\n -- REGISTER %s" % self._v_registered
        if self._v_registered: return
        get_transaction().register(Reporter(self))
        self._v_registered = 1


    def _unregister(self):
        try:
            del self._v_registered
            if self.id=='customize_items':
                print "\n_unregister: NORMAL OPERATION"
                # import traceback        
                # traceback.print_stack()        
        except:
            print "\n\n_unregister: ERROR----"
            # import traceback        
            # traceback.print_stack()
            
ZPatterns.Transactions.Reporter in most of the methods. Specifically:

    def tpc_begin(self, transaction, subtransaction=None):
        if self.client.id=='customize_items':    
            print '\n -- TPC begin %s sub=%s' % (self, subtransaction)
        self.tpc_entered = 1


Also: ZCatalog.py

    def catalog_object(self, obj, uid):
        """ wrapper around catalog """
        self._v_total = (self._v_total +
                         self._catalog.catalogObject(obj, uid,
self.threshold))

        if self.threshold is not None:
            if self._v_total > self.threshold:
                print ' -- ZCatalog commit subtransaction start'
                # commit a subtransaction
                get_transaction().commit(1)
                # kick the chache, this may be overkill but ya never
know
                self._p_jar.cacheFullSweep(1)
                self._v_total = 0
                print ' -- ZCatalog commit subtransaction complete'


The trace starts when I try to update a ZCatalog containing lots of
DataSkin-derived instances.

--------

 -- REGISTER 0

... lots of REGISTER 1

 -- REGISTER 1
 -- ZCatalog commit subtransaction start

 -- TPC begin <Products.ZPatterns.Transactions.Reporter instance at
89600f8> sub=1

 -- TPC commit <Products.ZPatterns.Transactions.Reporter instance at
89600f8>

 -- TPC finish <Products.ZPatterns.Transactions.Reporter instance at
89600f8>

 -- TPC end tran <Products.ZPatterns.Transactions.Reporter instance at
89600f8>

_unregister: NORMAL OPERATION
 -- ZCatalog commit subtransaction complete

 -- REGISTER None

 -- REGISTER 1

 -- TPC begin <Products.ZPatterns.Transactions.Reporter instance at
89f98b8> sub=1

 -- TPC commit <Products.ZPatterns.Transactions.Reporter instance at
89f98b8>

 -- TPC finish <Products.ZPatterns.Transactions.Reporter instance at
89f98b8>

 -- TPC end tran <Products.ZPatterns.Transactions.Reporter instance at
89f98b8>

_unregister: NORMAL OPERATION

 -- TPC commit_sub <Products.ZPatterns.Transactions.Reporter instance at
89600f8>

 -- TPC begin <Products.ZPatterns.Transactions.Reporter instance at
89600f8> sub=None

 -- TPC commit_sub <Products.ZPatterns.Transactions.Reporter instance at
89f98b8>

 -- TPC begin <Products.ZPatterns.Transactions.Reporter instance at
89f98b8> sub=None

_unregister: ERROR, can't del self._v_registered

--------

I don't know enough about ZODB transactions, and the intent of
ZPatterns.Transactions to do anything more at present.

I did note in ZODB/Transaction.py this comment. Perhaps it is relevant?


  # - For every jar for which we've called tpc_begin on,
  #   we either call tpc_abort or tpc_finish. It is OK
  #   to call these multiple times, as the storage is
  #   required to ignore these calls if tpc_begin has not
  #   been called.


--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net