[ZODB-Dev] Loading objects directly by OID

Jeremy Hylton jeremy@zope.com
Mon, 5 Nov 2001 07:50:22 -0500 (EST)


>>>>> "GW" == Greg Ward <gward@mems-exchange.org> writes:

  GW> Still haven't heard a whisper of a response on this problem.  It
  GW> seems complex, but right now all I want to know is one little
  GW> thing:

  GW>   Is it ever legal/possible for object A's pickle to contain a
  GW>   reference to OID B, but for B to not be loadable via the
  GW>   storage's load() method?

  GW> A simple "yes" or "no" will suffice.

I'd have offered one of those if I had known which one to offer
<wink>.

I suspect it isn't impossible or even illegal, although I suspect it
is frowned upon (immoral if not illegal).  I've never run into a
situation like this, and I think it should be avoided whenever
possible.  Not sure how hard this is to achieve in practice.

One scenario we have discussed as a theoretical risk might give you
some ideas.  Say we've got two objects, A and B, where A has a
reference to B.  An application loads A and B, modifies A so it no
longer refers to B, then commits a transaction (T1).  The application
still has references to A and B, but from the storage's point of view,
B is unreachable and can be collected.  So T1 is committed; then the
storage is packed and all traces of B are removed.  Then the app
creates a new object C that refers to B and commits it (T2).  B is not
modified by T2, so it doesn't get updated.  The storage now has an
object (C) with a reference to an unreachable object (B).

Jeremy