[erlang-questions] Ordering of mnesia events

Håkan Mattsson hm@REDACTED
Tue Dec 7 17:53:12 CET 2010

On Tue, Dec 7, 2010 at 5:07 PM,  <jensli@REDACTED> wrote:
> Hi,
> We’re developing an application where multiple processes on different
> nodes in a distributed system subscribe to mnesia events. The table is
> written to from one single process on one of the nodes.
> However uncertainty has arose about if we can be sure to receive the
> events in the same order as operations on the table.
> E.g:
> mnesia:delete(tab1, SomeRec),
> mnesia:write(tab1, SomeOtherRec)

The order of these events are undefined. In fact it is worse than that
as not all updates do result in an event. If you for example perform
two consecutive writes in the same transaction

  mnesia:write(tab1, SomeOtherRec)
  mnesia:write(tab1, YetSomeOtherRec)

they may result in one or two events depending on table type and the
primary key of the record. If the table is a set and two records have the
same key, only one event will be sent (the last write).

> If we sometimes get the delete event after the write event our design
> would not work and we would have to create some other kind of notification
> mechanism.
> Also, what about operations on different tables (from the same process)?
> mnesia:write(tab1, SomeRec),
> mnesia:write(tab2, SomeOtherRec)
> Can we be sure to always get the event from tab1 before the one from tab2?
> On all processes and all nodes?



More information about the erlang-questions mailing list