Richard Jones' Log: Fixing POSKeyErrors in Zope2.7
There's instructions at ZopeLab's cookbook on how to get in and fix POSKeyErrors. In my case, the objects are relatively anonymous BTrees, so finding them in order to delete them proves to be quite ... challenging. The following allows me to just pluck the offending object (as reported by fsrefs.py) from the pickle jar, and have a good look at it:
>>> from Zope.Startup.run import configure;configure('zope-8000/zope.conf') >>> from Zope import app; root = app() >>> from ZODB.POSException import POSKeyError >>> from ZODB.utils import p64 >>> o = root._p_jar[p64(0x277FEL)] >>> o OOBucket([('566', -1920968609), ...])
Note the configure line - that's necessary in Zope 2.7. Now, from the structure of the tree, I can hopefully determine where it might fit into our application (which makes heavy use of BTrees - something I'm starting to regret, with all the POSKeyErrors I'm pretty much constantly getting.
(yes, Zope's keeping me pretty busy these days)