[ZODB-Dev] Help: ZODB undo problem

Shane Hathaway shane@zope.com
Wed, 19 Jun 2002 23:33:55 -0400


Mike C. Fletcher wrote:
> Updates:
>     reset is definitely there in my copy of Zope3's ZODB (downloaded and 
> re-built today).  I'm thinking I wasn't clear in the problem statement 
> that it's Zope3, not Zope2 ZODB I'm using.  Leaving out any of the three 
             ^^^^^

Here's your problem.  You really can't expect Zope3 ZODB (aka ZODB4) to 
work well.  It's pre-pre-pre-alpha. ;-)

I just looked at the reset() method, and it really should not be there. 
  Someone apparently interpreted the presence of some code in Zope 2 as 
a requirement for new code.  I am the author of the original 
_resetCache() method (which reset() calls) and I wrote it only to 
support the Zope "Refresh" function.  It is dangerous--it will eat your 
objects alive.  Looks innocuous, doesn't it?  Well, what happens if you 
hold on to a reference to an object that has been severed from the cache 
using reset(), load a second copy of the object into the cache using 
normal mechanisms, then modify the disconnected object?  ZODB will 
become inconsistent.  Slowly, corruption will enter into your program. 
Next time you restart, ZODB will load your objects, but they might not 
be the objects you expected!  You may lose some hair! ;-)

Your program needs only the standard invalidation mechanisms, and they 
are always enabled.  If sync() does not solve the problem, it's very 
likely a ZODB bug, and you can't safely work around it with reset().

Why don't you use Zope2 ZODB?  It works fine with Python 2.2 and even 
2.3 (CVS).  It has been proven in battle.  sync() works.

Shane

P.S. unless there are any objections, I am going to remove the reset() 
method, so no one else falls into this trap.