[ZODB-Dev] RelStorage, history-free, pack causes POSKeyError with BTreeFolder2

Jim Fulton jim at zope.com
Mon Jan 31 13:14:52 EST 2011


On Fri, Jan 28, 2011 at 4:58 PM, Jürgen Herrmann
<Juergen.Herrmann at xlhost.de> wrote:
...
>  Afaics you use zodbpack's default of "days=0". This is known to produce
>  POSKeyErrors if the database is written to while packing.

It can lead to POSKeyErrors under certain pathological cases, but Is not
generally a problem in practice.

An example where it could be a problem:

    x = Foo()
    self._p_jar.add(x)
    transaction.commit()

At this point, x is in the database and is thus garbage.  For the sake
of this discussion, assume the database is packed to this point in
time and x is removed from the database.

    self.x = x
    transaction.commit()

At this point, self refers to an object that is no longer in the
db. At some later time, once self has been ghostified and x is removed
from local cache, if we try to access x, we'll get a poskey error.

I would argue that the application code above is broken.

Note that the storage could validate the reference to x when self is
saved, but no storage that I know of does, for performance reasons.
In some future version of ZODB, it might be nice to change the
database record structure to make this sort of check easier.


Jim

--
Jim Fulton
http://www.linkedin.com/in/jimfulton


More information about the ZODB-Dev mailing list