[ZODB-Dev] More "cPickleCache.incrgc" control (was: [Problem] "_v_" variables too volatile)

Dieter Maurer dieter at handshake.de
Sat Feb 7 11:33:39 EST 2004


In Dec. 2003, we have had an interesting discussion on how to provide
more "incrgc" control -- especially how to prevent "_v_" variables
to be flushed at subtransaction boundaries.

The attached patch against the Zope-Head CVS version
of 2004-02-07 provides more control as follows:

  *  Persistent objects get a new "_p_sticky" attribute which
     can be read and written (from Python).

     It is a boolean, but currently implemented (in "C") as a byte
     (just because byte access is more efficient than bit access).

     The "Sticky" state could not be used for this purpose
     as it is reset at transaction boundaries while
     our "_p_sticky" must remain until object deactivation

  *  "cPickleCache.incrgc" already had an ignored optional
     argument.
     This optional argument now gets the interpretation
     "mayFlushSticky" (and is no longer ignored).
     Its default is "True".

     If true, "incrgc" is allowed to deactivate objects
     with a true "_p_sticky". Otherwise, it must not deactivate
     such objects.

  *  "ZODB.Connection" is changed such that it calls "cPickleCache.incrgc"
     with "mayFlushSticky" true only in
     "setDB", "sync" and at boundaries of main transactions (and
     not subtransactions).

     As subtransaction handling is a bit convoluted :-(
     "incrgc" may be called with "mayFlushSticky=False"
     even when a main transaction is aborted (as it is not
     always clear whether a main or a subtransaction is aborted).

  *  "minimize" never flushes objects with "_p_sticky == True",
     as it is usually called asynchronously.


The patch does not automatically prevent "_v_" attribute flushing at
subtransaction boundaries. Only if "_p_sticky" is explicitely set to a true
value, a flush at subtransaction boundaries is prevented.

A "self->sticky = 1" in the "_v_" attribute handling
of "cPersistence:Per_setattro" 
would make "_v_" protection automatic but
most discussion contributors said "explicit is better than implicit"
and saw use cases where "_v_" variables need no protection.

-- 
Dieter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zodb_sticky.pat
Type: application/x-patch
Size: 9980 bytes
Desc: more "incrgc" control: new "_p_sticky" attribute
Url : http://mail.zope.org/pipermail/zodb-dev/attachments/20040207/604deb11/zodb_sticky.bin


More information about the ZODB-Dev mailing list