Database / Mnesia intermediate to advanced Interview questions
What is the {majority, true} table option and what tradeoff does it introduce?
Setting {majority, true} on a table requires that a write be acknowledged by a majority of the
nodes holding a copy of that table before the transaction is allowed to commit — if a network partition
leaves a node (or minority group of nodes) unable to reach a majority of replicas, writes on that isolated side
are refused rather than silently accepted.
mnesia:create_table(critical_config, [{disc_copies, [n1, n2, n3]}, {majority, true}, {attributes, [key, value]}]).
This directly trades availability for consistency during a partition: the minority side can't write at all until connectivity is restored, whereas without the option, both sides of a partition could keep accepting (potentially conflicting) writes independently. It's the closest thing Mnesia offers to a quorum-based consistency guarantee, at the cost of write availability on whichever side of a split doesn't hold a majority.
More Related questions...