[ZODB-Dev] Re: BTrees strangeness (was [Zope-dev] Zope 2.X BIG Session problems - blocker - our site dies - need help of experience Zope developer, please)

John Belmonte john at neggie.net
Wed Mar 3 22:53:40 EST 2004


Chris McDonough wrote:
> On Wed, 2004-03-03 at 22:20, Casey Duncan wrote:
> 
>>>>        for key in list(self._data.keys(None, max_ts)):
>>>>            assert(key <= max_ts)
>>>>            STRICT and _assert(self._data.has_key(key))
>>>>            for v in self._data[key].values():
>>>>                to_notify.append(v)
>>>>            del self._data[key]
>>
>>Maybe you could use items() and two loops instead;
>>
>>to_rm = []
>>for key, val in self._data.items(None, max_ts):
>>    for v in val.values():
>>        to_notify.append(v)
>>    to_rm.append(key)
>>for key in to_rm:
>>    try:
>>        del self._data[key]
>>    except Keyerror:
>>       pass # Somebody else deleted it first
>>
>>I don't think that could raise a KeyError...
> 
> 
> Well, the real bit of magic there is the "try.. except KeyError: pass"
> stanza.  Believe me, I'm tempted to stick that in, but this is the kind
> of voodoo that got me in to a lot of trouble in the older version of
> this code (there was reams upon reams of voodoo in the old code), so I'd
> really rather just figure out why the code is failing in the first
> place.  I'd just rather not mask the problem until I understand the
> cause.  That may never happen, of course, but a man can dream.

If I'm following this thread correctly, isn't the code failing because 
the BTree is corrupted (that is, BTrees.check.check chokes)?  If that's 
the case then you're certainly right to avoid masking the problem.

-John


-- 
http:// if  ile.org/



More information about the Zope-Dev mailing list