Database / Mnesia intermediate to advanced Interview questions
How does Mnesia decide which node's data wins during schema merge conflicts?
Left to its own defaults, Mnesia doesn't have an inherent basis for deciding whose data "wins" — when
two nodes reconnect and discover their schemas or table contents disagree, it raises an
inconsistent_database_event rather than guessing. Resolution happens through one of a few
explicit mechanisms you configure or invoke:
- Master nodes (
mnesia:set_master_nodes/2) — pre-designating an authoritative node for a table ahead of time. - A custom mnesia_event handler — subscribing to system events and implementing your own resolution policy in response to the inconsistency notification.
- Manual intervention — an operator inspecting both sides and using
force_load_table/1on whichever node's data should be treated as correct.
None of these happen automatically without configuration or explicit action — this is a deliberate design choice, since silently picking a winner risks quietly discarding legitimate data on whichever side loses.
More Related questions...