Skip to content

Commit

Permalink
Make leader_quorum_nodes_manager less noisy.
Browse files Browse the repository at this point in the history
When it terminates due to quorum_nodes getting modified from
outside. Most commonly this happens during rename and causes
confusion.

Detecting rename vs not-rename is not trivial, so I decided not to
spend time on it.

Change-Id: Ic73b16583538961ace4387f308419c07df0ebf06
Reviewed-on: https://review.couchbase.org/c/ns_server/+/167140
Well-Formed: Build Bot <build@couchbase.com>
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Tested-by: Aliaksey Artamonau <aliaksey.artamonau@couchbase.com>
  • Loading branch information
aartamonau authored and Aliaksey Artamonau committed Dec 8, 2021
1 parent ff16f52 commit fcadff5
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/leader_quorum_nodes_manager.erl
Expand Up @@ -157,8 +157,25 @@ handle_quorum_nodes_updated(#state{quorum_nodes = QuorumNodes} = State) ->
"Our quorum nodes: ~p~n"
"Their quorum nodes: ~p",
[QuorumNodesList, NewQuorumNodesList]),
exit({quorum_nodes_update_conflict,
QuorumNodesList, NewQuorumNodesList})

%% The idea here is that if our node thinks to be the leader, but
%% we somehow got a notification that some other node updated the
%% set of quorum nodes, that should mean that that other node also
%% thinks to be the leader and we neeed to terminate any leader
%% activities as soon as possible.
%%
%% But this case is also hit when we go through node rename, when
%% ns_config gets rewritten with the new node name. Detecting this
%% situation isn't very easy, and, it's actually ok to restart in
%% that case: in fact, after the rename all leader-related
%% processes are explicitly restarted anyway.
%%
%% Since the most common case when we hit this code is indeed
%% during node rename, to prevent any false alarms, terminate
%% quitely.
exit({shutdown,
{quorum_nodes_update_conflict,
QuorumNodesList, NewQuorumNodesList}})
end.

set_quorum_nodes_in_config(QuorumNodes) ->
Expand Down

0 comments on commit fcadff5

Please sign in to comment.