Database / Mnesia intermediate to advanced Interview questions
What is mnesia:set_master_nodes/2 used for?
mnesia:set_master_nodes(Table, Nodes) designates specific nodes as the authoritative source for
a table's data when Mnesia needs to decide which replica to trust — most notably when recovering from an
inconsistent database state after a network partition, where by default Mnesia can't automatically pick a
winner on its own.
mnesia:set_master_nodes(person, ['nodeA@host']).
By marking nodeA as the master for the person table, you're telling Mnesia that if
a conflict needs resolving, this node's copy should be treated as correct, and other replicas should sync from
it rather than the reverse. This is a proactive configuration step, typically set up as part of planned
disaster-recovery procedures, rather than something decided reactively in the middle of an actual partition
event.
More Related questions...