-
Notifications
You must be signed in to change notification settings - Fork 10
Description
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_graphsmap 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:
- Named graph nodes should give feedback if the associated CA is missing in registry #109
- Once Return a
ResultfromNode::exprto indicate invalid edges #58 is implemented, ensure
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:
- First, deal with commits that point to invalid graphs.
- 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.
- Update a
invalid_commitsmap from old invalid commit CAs to their new "valid" commit ca. - Clear the
invalid_graphsset.
- Update name -> commit mappings.
- 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_namesHashSet. - For all graphs, update all
NamedRefandFn<NamedRef>nodes whose names were just updated from the invalid commit to the new commit (i.e. their name appears inupdated_names, and the commit addr appears ininvalid_commits) to also point to the new commit. - If a graph was changed, add the change to the
invalid_graphsmap.
- For every name that points to an invalid commit, update its entry to point to the new commit and add the name to an
- 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.