[ZODB-Dev] Recovering from POSKeyErrors

Tim Peters tim at zope.com
Thu Jan 27 15:24:26 EST 2005


[ethan fremen]
> http://mindlace.net/src/zodb/killthem.py is the script I wrote to recover
> from POSKeyErrors.

Thanks!

> It is guaranteed to cause data loss.

Is that a money-back guarantee?

> It will not work if any of your objects is incapable of returning
> .objectItems() or doing .manage_delObjects() .

So it's probably dead in the water for standalone (non-Zope) uses of ZODB.
That's fine, just want it to be clear.

> It is intended for use as follows:
>
> $ zeoctl debug
> >>> from killthem import killthem
> >>> all = app.unrestrictedTraverse('/path/to/folder')
> >>> killthem(all)
>
> It will print a report of what object IDs it deletes. It traverses all
> objects below the first. It is reasonably conservative with memory use.
>
> As an (untested) option you may elect to destroy objects that raise some
> other exception, like:
>
> $ zeoctl debug
> >>> from killthem import killthem
> >>> from exceptions import Exception as LordKnows
> >>> all = app.unrestrictedTraverse('/path/to/folder')
> >>> killthem(all, excepting=LordKnows)
>
> The above is a very bad idea that deletes all objects that raise any
> exceptions.

If you think this possibility is of real potential use, then the recursive
calls in the function should be changed to pass on the `excepting` argument
(as is, passing `excepting` only affects the topmost invocation of
`killthem`).

> Caedite-eos! Novit-enim-Dominus-qui-sunt-eius-ly y'rs,

LOL!  That's the spirit.  Fixing database damage is a crusade in more than
one sense.



More information about the ZODB-Dev mailing list