[erlang-questions] Mnesia system events and table events
Hakan Mattsson
hakan@REDACTED
Tue Oct 9 10:36:51 CEST 2007
On Sun, 7 Oct 2007, Alexander Lamb wrote:
AL> Is this the way to go? In details:
AL>
AL> 1) is using table events in Mnesia a usual way to notify other processes of
AL> changes?
Yes.
AL> 2) I suppose the events are sent aynchronously... what about performance
AL> issues?
Yes, events are sent asynchronously. They are just
plain Erlang messages. In order to ensure that the
performance is good enough for your configuration and
access patterns you need to perform some measurements
yourself.
AL> 3) If I have a multi-node Mnesia database, I suppose I will only receive one
AL> event per event (not one per node)?
No. The subscription mechanism in Mnesia is a local feature.
When a table is updated, Mnesia will update all table
replicas and for each replica a local message will be
sent to the local subscribers.
AL> 4) If this is the way to go, would you send on the bus:
AL> a) the Name and Key of the record(s) which changed (leaving the
AL> listening, non Erlang process to refetch immediately after what it needs)
AL> b) the complete record(s), event the attributes which didn't change
AL> c) only the changed attributes
B. See the documentation:
http://www.erlang.org/doc/apps/mnesia/Mnesia_chap5.html#5.7
AL> I was thinking of converting the events in JSON messages which could be
AL> listened to from any non-Erlang process.
How do you to take care of updates that don't make it
all the way to your external non Erlang process?
For example, events may be lost if the Erlang node
crashes after Mnesia has committed the update to the
database but before your external non-Erlang process
has handled it.
/Håkan
More information about the erlang-questions
mailing list