[erlang-questions] Ordering of mnesia events

jensli <>
Wed Dec 8 09:12:20 CET 2010


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? On all nodes?


/JL

>
> 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)

> /Håkan
> On Tue, Dec 7, 2010 at 5:07 PM,  <> 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?
>
> No.
>
> /Håkan
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
>
>





More information about the erlang-questions mailing list