Find broken parents of RelationValues

I recently had a problem where a folderish object (with some files and pages in it) had an export size of 34GB. After some days of tedious analysis, I noticed that unrelated content gets exported as well. I tracked it down to 2 fields (RelationLists), each having one RelationValue-element with a “wrong” __parent__ set (to some dangling object within the DB). It looks like Relations not handled for folderish content · Issue #118 · plone/ · GitHub is the cause of this. However, I would like to know if there are other objects with a huge export/copy-size. Is there any way to identify a “wrong” parent?

I started with a script but it gave me out 10000 wrong parents (out of 95000) and many of them don’t have a huge size when exporting.

Script to identify wrong parents

This is the most important part of the script. Before this I use the Catalog to access the find the objects, access them and check the fields with relationvalues/lists.

    def analyse_relation(self, rel_item, obj):
        if not rel_item:
            return True

        if not IRelationValue.providedBy(rel_item):
            return True

        if obj.portal_type in ["File", "Image"]:
            grandparent_is_set_as_parent = (
                obj.aq_parent.aq_parent.aq_base == rel_item.__parent__
            parent_is_set_as_parent = obj.aq_parent == rel_item.__parent__
            self_is_set_as_parent = obj == rel_item.__parent__
            return (
                or parent_is_set_as_parent
                or self_is_set_as_parent

        return rel_item.__parent__ == obj

Btw.: For my original case I deleted the relationvalues (both fields are not used anymore) and the export is now 7.5MB.

This is a useful tool: GitHub - collective/collective.relationhelpers: Helpers to manage, create, export and rebuild relations in Plone 5.x. For Plone 6 this was merged into Plone core.

1 Like

@adrianschulz I'm Not 100% sure if this also relates to your issues. On my end, the problem were parent pointers of RelationValues, which prevented the ZODB from getting rid of objects them during packing. See detailed analysis here: Image scale blobs no cleaned by zeopack after removing ScalesDict - #7 by maethu

1 Like