Skip to content

On startup, validate graph Registry #147

@mitchmindtree

Description

@mitchmindtree

Currently, if the registry storage is corrupted, or a graph's CA would have changed between runs, we end up with errors or inconsistent state.

We should make sure to validate the registry when gantz starts up.

  • Check graph addrs match the graphs they point to. For those that no-longer match their graph addr key:
    • Remove the old entry with a warning.
    • Re-add the graph under its new CA.
    • Create an entry in a new invalid_graphs map stored in the environment (old addr -> new addr).

Notably, we do not alter any commit or name entries as the user might have just accidentally opened their graphs in an older/newer version of gantz or something, and don't actually want their node addresses to change.

Instead, we ensure that:

Updating Names and Commits

The invalid_graphs map should be handy to allow users to "update" invalidated names (used by NamedRef and Fn<NamedRef> nodes) to a new commit that points to the new CA for the graph.

When doing this, we should start with updating the most deeply nested nodes first. This is because updating any nested nodes will invalidate the parent graph CA again.

Rather than allowing for updating individual names, it might make more sense to only allow for updating all named nodes at once to ensure everything is updated in one big step.

While coming up with an approach, worth remembering iterating over commits from oldest to newest automatically gives us a valid topo ordering.

The algo would likely need to be iterative and may end up looking something like this:

  1. First, deal with commits that point to invalid graphs.
    1. For every commit pointing to an invalid graph ca, create a new commit that instead points to the new valid graph ca. Use the old invalid commit as the parent.
    2. Update a invalid_commits map from old invalid commit CAs to their new "valid" commit ca.
    3. Clear the invalid_graphs set.
  2. Update name -> commit mappings.
    1. For every name that points to an invalid commit, update its entry to point to the new commit and add the name to an updated_names HashSet.
    2. For all graphs, update all NamedRef and Fn<NamedRef> nodes whose names were just updated from the invalid commit to the new commit (i.e. their name appears in updated_names, and the commit addr appears in invalid_commits) to also point to the new commit.
    3. If a graph was changed, add the change to the invalid_graphs map.
  3. If there are no more invalid_graphs, we're done. Otherwise, go back to step 1.1.

For every update of a graph, commit or name from a previous address to a new address, we should debug log the event.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bugSomething isn't working🕸️ gantzRelated to the top-level `gantz` crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions