Mnesia, more questions

Ulf Wiger (AL/EAB) <>
Tue Aug 30 16:53:37 CEST 2005


But this solution doesn't handle transaction aborts.

How do you deal with that?

/Uffe

Claes Wikstom wrote:
>
> 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 = Ts#tidstore.store,
> 			    ok = log_transaction(Store, R),
> 			    Res;
> 		       true ->
> 			    Res
> 		    end;
> 		_ ->
> 		    Res
> 	    end
>      end,
>      mnesia:transaction(F).
> 
> 
> 
> 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
> 
> 
> 
> /klacke
> 
> 
> 
> 
> 



More information about the erlang-questions mailing list