Database / Mnesia basics Interview questions
How does Mnesia keep replicated tables consistent across nodes?
Every write inside a transaction on a replicated table is propagated to all nodes holding a copy as part of that same transaction's commit, coordinated through a two-phase commit protocol: a coordinating node asks each replica to prepare the write, and only tells them all to actually commit once every replica has confirmed it can.
sequenceDiagram
participant Coord
participant NodeA
participant NodeB
Coord->>NodeA: prepare write
Coord->>NodeB: prepare write
NodeA-->>Coord: ready
NodeB-->>Coord: ready
Coord->>NodeA: commit
Coord->>NodeB: commit
If any replica can't prepare (it's unreachable, or has a conflicting lock), the whole transaction aborts on every node rather than applying on some and not others — this is precisely what gives Mnesia its all-or-nothing consistency guarantee across a cluster rather than just within a single node.
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...
