Database / Mnesia intermediate to advanced Interview questions
What is the difference between async_dirty and sync_dirty activity contexts?
Both are non-transactional access contexts you can use with mnesia:activity/2 or by directly
calling dirty functions, trading Mnesia's usual locking/atomicity for speed — the difference between
them is, again, about replication timing rather than locking.
| async_dirty | sync_dirty |
| Returns as soon as the local write succeeds; replicates to other nodes in the background. | Waits for the write to be applied on every replica before returning. |
| Fastest option; least consistency guarantee. | Slightly slower; stronger guarantee that replicas are caught up when the call returns. |
mnesia:activity(sync_dirty, fun() -> mnesia:write(#metric{id = 1, value = 42}) end).
Neither context provides transactional atomicity across multiple operations or locking against concurrent
writers — both remain "dirty" in that sense; sync_dirty just narrows the window where a
reader on another node could see stale data immediately after a write.
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...
