How long does mnesia take to warm up?

Joe Armstrong (AL/EAB) joe.armstrong@REDACTED
Thu Sep 8 16:06:40 CEST 2005


   When I evaluate mnesia:start() it seems to take a little time before mnesia is
ready to do what I tell it - is this a bug? - do I really have to busy-wait
before it is ready?

   I have made myself a little mnesia table called mom_types
 
   In this run I have to make 34 attempts to write the table, attempts 1 to 34 fail because there is no such table, but 35 succeeds because suddenly there *is* a table.

   Alternatively I can wait for half a second or so after starting mnesia
   
   I guess this is a synchronisation error in the start-up?

	/Joe



Eshell V5.3  (abort with ^G)
1> bug:start()
Oh dear N=0 {aborted,{no_exists,mom_types}}
Oh dear N=1 {aborted,{no_exists,mom_types}}
...
Oh dear N=33 {aborted,{no_exists,mom_types}}
Oh dear N=34 {aborted,{no_exists,mom_types}}
At last N=35 ok
true
 

-module(bug).

-export([start/0]).

start() ->
    mnesia:start(),
    do(0).

do(N) ->
    V = mnesia:transaction(fun() ->
				   mnesia:write({mom_types,a,b})
			   end),
    case V of
	{atomic, X} ->
	    io:format("At last N=~w ~p~n",[N, X]),
	    true;
	Other ->
	    io:format("Oh dear N=~w ~p~n",[N, Other]),
	    do(N+1)
    end. 



More information about the erlang-questions mailing list