Prev Next

Database / Mnesia intermediate to advanced Interview questions

How does setting master nodes influence conflict resolution after a network partition?

When a partition heals and Mnesia detects that a table's replicas diverged, its default behavior is to raise an inconsistent_database_event and leave the decision of which side to trust to an operator or a configured event handler, since it has no inherent basis to prefer one side over the other. Master node configuration removes that ambiguity ahead of time for a given table.

flowchart TD
    A[Partition heals, conflict detected] --> B{Master node configured for this table?}
    B -->|Yes| C[Master node's data treated as authoritative; other replicas resync from it]
    B -->|No| D[inconsistent_database_event raised; manual/handler resolution required]

With master nodes set, the recovery process becomes more automatic and predictable: replicas that disagree with the designated master simply resync to match it, rather than requiring someone to manually inspect both sides and decide (potentially under time pressure during an incident) which one to keep.

Without a configured master node, what does Mnesia do when it detects conflicting replicas?
What happens to non-master replicas that disagree with the master's data?

Invest now in Acorns!!! 🚀 Join Acorns and get your $5 bonus!
Acorns Logo

Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!

Earn passively and while sleeping

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.

Robinhood Logo

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 Logo

Webull! Receive free stock by signing up using the link: Webull signup.

More Related questions...

What is the difference between mnesia:transaction/1 and mnesia:sync_transaction/1? What is the difference between async_dirty and sync_dirty activity contexts? How does mnesia:activity/4 let you customize the access context of an operation? What is table fragmentation in Mnesia and why would you use it? How do you configure a fragmented Mnesia table? Why does fragmentation help Mnesia scale beyond what one table replica set can handle? What is the difference between mnesia:match_object/1 and mnesia:select/2? What is mnesia:all_keys/1 used for? How do you integrate Mnesia with QLC for complex queries? Why would you use qlc:q with mnesia:table/1 instead of mnesia:select/2? What is a sticky lock in Mnesia and why does it improve performance? When can sticky locks cause a problem in a distributed Mnesia cluster? How do you dynamically add a new node to a running Mnesia cluster? What is mnesia:change_config(extra_db_nodes, Nodes) used for? How do you remove a table replica from a node without dropping the whole table? What is mnesia:del_table_copy/2 used for? How do you move a table copy from one node to another while the system stays live? What is mnesia:move_table_copy/3 used for? What is the {majority, true} table option and what tradeoff does it introduce? Why would you enable the majority option on a table prone to network partitions? What is a local_content table in Mnesia? When would you use a local_content table instead of a normal replicated table? What is mnesia:set_master_nodes/2 used for? How does setting master nodes influence conflict resolution after a network partition? What is mnesia_tm and what role does it play internally? How does Mnesia's transaction manager serialize concurrent transactions touching the same records? Why can a "hot" record or table become a bottleneck under heavy Mnesia write load? How can you redesign a schema to reduce lock contention on a frequently-updated record? What is mnesia:subscribe/1 used for? How do you react to table events using Mnesia's subscription mechanism? What is a nested Mnesia transaction and how does it behave differently from a top-level one? Why should nested transactions generally be avoided or used carefully in Mnesia? What is the dc_dump_limit configuration parameter used for? Why does tuning the transaction log dump frequency matter for write-heavy Mnesia workloads? How do you merge two previously-separate Mnesia clusters into one? What complications arise when merging schemas from two independently-created Mnesia databases? How does Mnesia decide which node's data wins during schema merge conflicts? What is the difference between a global lock and a per-record lock in Mnesia transactions? When would you use mnesia:read_lock_table/1 instead of relying on per-record locks? How do you profile and optimize Mnesia transaction throughput in a write-heavy system? Why is batching multiple related writes into a single transaction usually better than many small transactions? How does Mnesia's schema interact with OTP release upgrades (appup/relup)? What is the difference between mnesia:dirty_all_keys/1 and mnesia:all_keys/1? Explain the internal working of how Mnesia chooses which replica to read from in a load-balanced cluster? What is the where_to_read table_info item used for? What is mnesia:dump_log/0 used for? How do you handle a transaction that needs to retry after being aborted due to a deadlock? What is the difference between mnesia:transaction/1's built-in behavior and manual retry logic you might add?
Show more question and Answers...

Integration

Comments & Discussions