powsybl / powsybl-afs

AFS modules for powsybl
Mozilla Public License 2.0
3 stars 1 forks source link

[Cassandra] Orphan node check #87

Open sylvlecl opened 3 years ago

sylvlecl commented 3 years ago

Feature

It's easy to create orphan nodes (nodes without a parent): we must provide a way to identify them and delete them:

    void testOrphanNodes() {
        NodeInfo orphanNode = storage.createNode(UUIDs.timeBased().toString(), "orphanNodes", FOLDER_PSEUDO_CLASS, "", 0, new NodeGenericMetadata());
        //Following throws because data such as modification date are null for the unexisting parent node
        storage.getParentNode(orphanNode.getId());
    }

Provide an ORPHAN_NODES check in CassandraAppStorage. It will identify the nodes which have a null parent ID. The repair will simply delete those nodes.

Being able to delete orphan nodes, which are not accessible from the user API, but may cause issues (disk usage or null pointer in some functionalities).

Note that we don't perform a check on the parent existence when we create a node. We can add this kind of check, but it adds an additional query without completely solving the issue : we could still create orphan nodes because of concurrency issues. Therefore that tool remains necessary anyway.