Mnesia, more questions

Claes Wikstom <>
Tue Aug 30 16:24:07 CEST 2005

Hakan Mattsson wrote:

> Yet another solution is to have a front-end which stores all
> updates into a persistent queue, and a back-end which reads
> operations from the queue and performs updates of the
> primary Mnesia database. The persistent queue should also be
> processed on the secondary site, but there you would be more
> free to choose the timepoint for when the database updates
> are performed. Using this method it would be much easier to
> recover from a communication or site failure than with the
> other two methods.

This is pretty close to what we've done.

We have wrapped mnesia:transaction in yet another
function of ours, foo:transaction()

as in: foo.erl

transaction(Fun, As) ->
     F =
     fun() ->
	    Res = apply(Fun, As),
	    case mnesia:get_activity_id() of
		{_, _, Ts} ->
		    if Ts#tidstore.level == 1 ->
			    Store =,
			    ok = log_transaction(Store, R),
		       true ->
		_ ->

log_transaction(TS, Ref) ->

     Bin = term_to_binary(ets:tab2list(TS)),

	... send this transaction (The Bin) to some log
	outside of the system.
	The Bin can then be replayed there


More information about the erlang-questions mailing list