Database / Mnesia intermediate to advanced Interview questions
What is mnesia_tm and what role does it play internally?
mnesia_tm is Mnesia's internal transaction manager process — the component actually
responsible for coordinating a transaction's lifecycle: acquiring locks, tracking what a transaction has
read/written, driving the two-phase commit exchange with other nodes for replicated tables, and deciding
whether to commit or abort.
flowchart LR
A[mnesia:transaction Fun] --> B[mnesia_tm coordinates locks + commit protocol]
B --> C[Local storage: ETS/DETS tables updated]
B --> D[Remote replicas: 2PC coordination]
It's not something application code calls directly — it's the machinery behind
mnesia:transaction/1 and related functions, handling the bookkeeping so your transaction function
just reads and writes records without needing to manage locks or replication itself. Understanding its
existence matters mainly for debugging deep issues (deadlocks, stuck transactions) where its internal state
(visible via tracing or mnesia:info/0) is what you'd inspect.
More Related questions...