CONFD_ERR_HA_BADNAME error code 29

Hi everyone , i try to setup high avaiable for 2 servers : S1 and S2 , there are 2 cases below

  • S1 up first to be master : i check my application’s log and get the error code 29 - CONFD_ERR_HA_BADNAME which is result of calling function econfd_ha:beslave/4
  • S2 up first to be master : run normaly…
    where am i wrong ? anyone can tell me about the 29 error code ? thank you so much

From the confd_lib_lib(3) man page:
CONFD_ERR_HA_BADNAME (29)
A remote ha node has a different name than the name we think it has.

So you are not using the same name as the “active” has when calling beslave for the “standby”. There are no good examples in the ConfD example set or econfd API documentation, so a few examples below.

benone(N) ->
    {ok, S} = econfd_ha:connect({127,0,0,1}, ?CONFD_PORT + N, <<"foobar">>),
    ok = econfd_ha:benone(S),
    econfd_ha:close(S),
    ok.

beactive(N) ->
    {ok, S} = econfd_ha:connect({127,0,0,1}, ?CONFD_PORT + N, <<"foobar">>),
    NodeId = list_to_binary("node" ++ integer_to_list(N)),
    ok = econfd_ha:bemaster(S, NodeId),
    econfd_ha:close(S),
    ok.

bestandby(N, ActiveN) ->
    {ok, S} = econfd_ha:connect({127,0,0,1}, ?CONFD_PORT + N, <<"foobar">>),
    Active = #ha_node{
      addr = {127,0,0,1},
      nodeid = list_to_binary("node" ++ integer_to_list(ActiveN)) },
    NodeId = list_to_binary("node" ++ integer_to_list(N)),
    ok = econfd_ha:beslave(S, NodeId, Active, 1),
    econfd_ha:close(S),
    ok.

dead_standby(N, NStandby) ->
    {ok, S} = econfd_ha:connect({127,0,0,1}, ?CONFD_PORT + N, <<"foobar">>),
    NodeId = list_to_binary("node" ++ integer_to_list(NStandby)),
    ok = econfd_ha:slave_dead(S, NodeId),
    econfd_ha:close(S),
    ok.

get_status(N) ->
    {ok, S} = econfd_ha:connect({127,0,0,1}, ?CONFD_PORT + N, <<"foobar">>),
    {ok, Status} = econfd_ha:getstatus(S),
    io:format("status node~w: ~s\n", [N, fmt_status(Status)]),
    econfd_ha:close(S),
    case Status#ha_status.status of
        ?CONFD_HA_STATE_NONE  -> none;
        ?CONFD_HA_STATE_SLAVE -> {slave,
                                  (hd(Status#ha_status.data))#ha_node.nodeid};
        ?CONFD_HA_STATE_MASTER -> {master, length(Status#ha_status.data)}
    end.

fmt_status(#ha_status{ status = S, data = D }) ->
    case S of
        ?CONFD_HA_STATE_NONE ->
            "none";
        ?CONFD_HA_STATE_SLAVE ->
            io_lib:format("standby active: ~s",
                          [binary_to_list((hd(D))#ha_node.nodeid)]);
        ?CONFD_HA_STATE_MASTER ->
            io_lib:format("active ~w standbys:~s",
                          [length(D),
                           lists:map(
                             fun (N) ->
                                     [" ", binary_to_list(N#ha_node.nodeid)]
                             end, D)])
    end.

check_status(N, Expect) ->
    Expect = get_status(N),
    ok.

yea pro, i resolved it … thank you so much