[erlang-questions] Ordering of mnesia events

Håkan Mattsson hm@REDACTED
Wed Dec 8 11:17:47 CET 2010


2010/12/8  <jensli@REDACTED>:
> Thanks for your answer.
>
> Ok, so when operations happen in a transactions we cant be sure about
> much, only that all the operations in the transaction are considered to
> happen at once with no defined order, and we can only expect events that
> reflect the final result of the transaction.
>
> But what about dirty operations?
>
> Same table:
> mnesia:dirty_delete(tab1, SomeRec),
> mnesia:dirty_write(tab1, SomeOtherRec)
>
> Different tables:
> mnesia:dirty_write(tab1, SomeRec),
> mnesia:dirty_write(tab2, SomeOtherRec),
>
> Obviously, they will happen in a defined order. But does that also hold
> for the events?

If it is the same process that performs all these dirty calls and the involved
tables resides on the local node, the events will be delivered in the same
order as they are performed to subscribers on the local node. This is the
current behavior and it is very unlikely to be changed. But as it not is
explicitly stated in the documentation you should not rely on the current
behavior.

> On all nodes?

There is no global ordering in the sense that event #1 will be delivered
to subscribers on all nodes before event #2 is delivered. But the events
will occur in the same order on all nodes which have a replica of the
table if it is the dirty updates originates from the same process. But
as this is not documented...

/Håkan


More information about the erlang-questions mailing list