Partitioned network solving

Vladimir Sekissov <>
Wed Mar 20 01:37:02 CET 2002


Good day,

I'm bother on partitioned network solving in my distributed
application. It seems that for global names conflict resolving later
registered processes are unregistered. So I register global process in
my application and use modified version of Ulf Wiger nodemon.erl
(# Message-Id: <>) and
code below on all application nodes, but I'm not sure that this solution
fully correct. Can somebody point me to possible troubles.

Another question - I don't use dist_auto_connect = once in config file
but when I have suspended one node with Ctrl-G from shell they don't
try to connect after and I need to ping one of them explicitly.

%%
%% nodemon_handler(FromNode, State) -> {Action, NewState}
%%    called by nodemon when network partitioning detected
%%       FromNode - node detected as partitioned
%%       State    - handler state
%%       Action   - stop | restart | reboot | nothing
%%       NewState - new handler state
%%
nodemon_handler(FromNode, State) -> 
  %% tac_master - application globally registered process
  case global:whereis_name(tac_master) of
    undefined ->
      ?LOG_ERROR("Partitioned network (~p,~p), no tac_master",
                [node(), FromNode]),
      {nothing, State};
    _ ->
      
      MasterNode = wait_name_resolve(FromNode),
      if MasterNode == node() ->
          %% we are master in low
          %% global has already unregistered process on backup node
          {nothing, State};
         %% we are syncing with master only
         MasterNode == FromNode ->
          mnesia:set_master_nodes([MasterNode]),
          {restart, State};
         %is not a master skip it
         true ->
          {nothing, State}
      end
  end.

wait_name_resolve(RemNode) ->
  OurVsn = node(global:whereis_name(tac_master)),
  RemVsn =
    case rpc:call(RemNode, global, whereis_name, [tac_master]) of
      {badrpc, _} ->
        OurVsn;
      RemPid ->
        rpc:call(RemNode, erlang, node, [RemPid])
    end,
  if OurVsn == RemVsn -> OurVsn;
     true -> wait_name_resolve(RemNode)
  end.


---
Best Regards,

Vladimir Sekissov



More information about the erlang-questions mailing list