Removing "undeleteable" objects from ZODB

View: New views
2 Messages — Rating Filter:   Alert me  

Removing "undeleteable" objects from ZODB

by Eugene Morozov-3 :: Rate this Message:

| View Threaded | Show Only this Message

Hello,
I have a very old Zope instance (it was upgraded from Zope 2.4 to Zope 2.7 and later to Zope 2.13) that has a number of problems. There're instances of products that no longer exist, for example. They can't be removed by using any means. They can't be removed from Zope user interface (some of them aren't even visible). They can't be removed from python prompt as described in this document:
http://zodb.org/documentation/articles/multi-zodb-gc.html

The simplest script to replace broken object with some pristine object doesn't work:
replace_obj = OrderedFolder('removeme')
replace_obj._p_oid = p64(BROKEN_OBJECT_ID)
replace_obj._p_jar = app._p_jar
app._p_jar._register(replace_obj)
app._p_jar._added[p64(BROKEN_OBJECT_ID)] = replace_obj

This code always fails because with the following exception:
ConflictError: database conflict error (oid 0x0db8, class OFS.OrderedFolder.OrderedFolder, serial this txn started with 0x00 1900-01-01 00:00:00.000000, serial currently committed 0x03384864da015019 2000-11-05 00:36:51.094952)

As far as I understand ConflictError is raised because transaction code always attempts to read broken object and compare it with the new object. I couldn't find any working way to remove such broken objects from the database and they often get in the way. :(

Is there some other way to remove them?
Eugene

_______________________________________________
For more information about ZODB, see http://zodb.org/

ZODB-Dev mailing list  -  ZODB-Dev@...
https://mail.zope.org/mailman/listinfo/zodb-dev

Re: Removing "undeleteable" objects from ZODB

by Shane Hathaway :: Rate this Message:

| View Threaded | Show Only this Message

On 12/19/2011 02:50 AM, Eugene Morozov wrote:
> Is there some other way to remove them?

I would remove all references to the broken objects, then let packing
wipe the old objects away. For example:

container = app['somefolder']
del container[obj_name]

It's possible to replace objects in the manner you posted, but it's
usually a bad idea. If you really must do it, you have to set the
_p_serial to the _p_serial of the existing object, which you can get
using app._p_jar._storage._load(oid).

Shane
_______________________________________________
For more information about ZODB, see http://zodb.org/

ZODB-Dev mailing list  -  ZODB-Dev@...
https://mail.zope.org/mailman/listinfo/zodb-dev