Improve how we apply database migrations #4009
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the hosted service, restarting a node can take a long time. That can be almost entirely attributed to the fact that we rebuild the fdw mappings between shards on every start, and sometimes nodes have to wait for other activity to stop before that rebuild can happen. We rebuild the mappings on every start since we don't properly propagate whether the schema in a shard was changed to the other shards that import tables from that shard.
With this PR, the fdw mappings are only rebuilt if there were actually schema changes, i.e., in the vast majority of cases the rebuild can be skipped and startups will be much faster.
Since interrupting
graph-node
startup at the wrong time (right after migrations ran but before remapping is done) can cause fdw mappings to not be updated,graphman
now has a commandgraphman database remap
to kick off remapping manually.It also now has a command
graphman database migrate
to apply schema migrations, thoughgraph-node
still does that on startup.