[erlang-questions] Mnesia and concurrency

Hakan Mattsson <>
Fri Dec 22 10:04:43 CET 2006


On Thu, 21 Dec 2006, Yariv Sadan wrote:

YS> I'm not a database guru, so forgive me if some of my assumptions are
YS> wrong, but if I understand it correctly, many DBMS engines employ some
YS> type of one-writer/multiple-readers concurrency strategy to prevent
YS> long reads from becoming bottlenecks. This requires multiple threads
YS> to be able to read a table concurrently, which implies that the table
YS> is shared between multiple threads. In Erlang, this isn't an option
YS> (at least, not if the data is in RAM), so, does that mean that Mnesia
YS> tables can only be read by one process at a time?

No, the same goes for Erlang and Mnesia. The difference
against other systems is that in Erlang we do not need
separate OS threads to achieve this. It suffices to use
separate Erlang processes (which may be hosted by any
connected Erlang node). Any number of Erlang processes
may read the same record without causing a locking
conflict. But if one Erlang process is grabbing a write
lock, it will get an exlusive lock for that record. The
same principle is also valid for table locks.

/Håkan


More information about the erlang-questions mailing list