Open psviderski opened 5 days ago
That's a great question. Schema synchronization has been largely left to users.
At Fly: We have a repository containing Corrosion-related configuration that we deploy independently.
Usually this is a multi-step process, similar to a migration for a normal database:
If we do this properly, every node has the same schema and there are no errors. If there are no errors, that's ok because nodes will keep trying to synchronize versions they haven't been able to apply.
It's not perfect and a bit tedious... if you want to distribute the schema automatically via Corrosion, that sounds doable in the way you've described it, but a little scary sometimes. Automatic schema propagation was something we decided not to do to keep more explicit control of what happens to the schema.
When DB schema is changed (e.g. a new column is added) on node A and not on node B, inserts/updates from node A using new schema fail to apply on node B:
A similar error occurs when trying to process a change for a new table that doesn't exist on node B:
This behavior seems reasonable to prevent data loss. However, it requires every node in the cluster to run the same schema version. To comply with that requirement, what should be the process for deploying schema changes to the cluster? One approach could be having another distributed table that would store the latest schema along with a separate process that would watch the latest schema and synchronize it to
db.schema_paths
followed by executingcorrosion reload
. Is there a better way to handle this? How do you manage schema changes at Fly?