[ZODB-Dev] self.length._p_deactivate() and MVCC

Jeremy Hylton jeremy at alum.mit.edu
Fri Apr 30 08:37:42 EDT 2004


On Fri, 2004-04-30 at 04:03, Thomas Güttler wrote:
> By chance I came across this comment
> in the code of Lexicon.py of ZCTextIndex.py:
> 
>     def sourceToWordIds(self, text):
>         last = _text2list(text)
>         for element in self._pipeline:
>             last = element.process(last)
>         if not hasattr(self.length, 'change'):
>             # Make sure length is overridden with a BTrees.Length.Length
>             self.length = Length(self.length())        
>         # Strategically unload the length value so that we get the most
>         # recent value written to the database to minimize conflicting wids
>         # XXX this will not work when MVCC is implemented in the ZODB...
>         self.length._p_deactivate() # <------------------------
>         return map(self._getWordIdCreate, last)
> 
> Can someone explain this, and why this does not work with MVCC?

I think the person who wrote the comment believed that the old value of
length would be loaded again if MVCC was enabled.  The Length object has
an _p_independent() method, however.  The return value of that method
tells ZODB whether it is okay to read a revision of the object that is
inconsistent with other objects.  Length's _p_independent() always
returns 1, so ZODB will always read the most current revision.

Jeremy





More information about the ZODB-Dev mailing list