[erlang-questions] Replicated Mnesia table on dynamic nodes - how?
Paul Mineiro
paul-trapexit@REDACTED
Tue Jul 7 20:00:20 CEST 2009
http://erlanganswers.com/web/mcedemo/mnesia/DistributedHelloWorld.html
-- p
p.z. Sounds like you want http://code.google.com/p/schemafinder/
On Tue, 7 Jul 2009, Jacek Furmankiewicz wrote:
> OK, so how would you write common code to make sure a node creates the
> initial schema (if it's the first one) or adds itself to an existing schema
> (if another node has already created one).
>
> I had this type of logic to create a schema on startup:
> *
> case mnesia:create_schema([node()]) of
> {atomic,ok} -> ok;
> {error,{_,{already_exists,_}}} -> ok;
> Error ->
> error_logger:error_msg("Failed to create Mnesia schema:
> ~p.~nStopping application.~n",[Error]),
> init:stop(1)
> end,*
>
> and then tried something like this for a new node to attach itself:
> *
> case mnesia:change_config(extra_db_nodes,node()) of
> {ok,_Nodes} -> ok;
> {error, Reason} ->
> error_logger:error_msg("Failed to connect to Mnesia schema:
> ~p.~nStopping application.~n",[Reason]),
> init:stop(1)
> end,*
>
> Our app does not have a single "master" node, all nodes are equal. The
> system should basically auto-configure Mnesia (create schema by first node
> that gets created, attach itself to an existing schema for all other nodes).
> I'm not quite sure how to write this single code that all nodes could use to
> reliably fulfill this requirement...
>
> Cheers, Jacek
>
More information about the erlang-questions
mailing list