Database / Mnesia basics Interview questions
How does Mnesia resolve conflicts after a network partition heals?
When a network partition splits a cluster, each side can keep operating independently on its own copy of a replicated table, potentially applying different, conflicting writes to the same records on each side. When the partition heals and the nodes reconnect, Mnesia detects this as an inconsistent database state rather than silently merging the two histories.
flowchart TD
A[Partition heals, nodes reconnect] --> B{Mnesia detects differing table state?}
B -->|Yes| C[Reports inconsistent_database_event]
C --> D[Application-supplied or default resolver decides which side wins]
D --> E[Losing side's conflicting changes are discarded]
By default, Mnesia doesn't automatically pick a winner for you in a way that guarantees no data loss —
it raises an inconsistent_database_event and expects either a configured
mnesia_event handler or manual operator intervention (often via
mnesia:force_load_table/1 on the side chosen as authoritative) to resolve it. This is precisely
why systems that can't tolerate this ambiguity often add their own quorum or leader-election logic on top,
rather than relying on Mnesia's partition handling alone.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
