Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Valiushko committed Jan 25, 2024
1 parent 70fa978 commit 7944515
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/ra_server_proc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,13 @@ follower_leader_change(Old, #state{pending_commands = Pending,
aten_register(Node) ->
case node() of
Node -> ok;
_ -> aten:register(Node)
_ ->
case aten:register(Node) of
ignore ->
ok;
Res ->
Res
end
end.

swap_monitor(MRef, L) ->
Expand Down Expand Up @@ -1552,24 +1558,24 @@ do_state_query(voters, #{cluster := Cluster}) ->
do_state_query(members, #{cluster := Cluster}) ->
maps:keys(Cluster);
do_state_query(members_info, #{cfg := #cfg{id = Self}, cluster := Cluster,
leader_id := Self, query_index := QI, commit_index := CI,
membership := Membership}) ->
leader_id := Self, query_index := QI, commit_index := CI,
membership := Membership}) ->
maps:map(fun(Id, Peer) ->
case {Id, Peer} of
{Self, Peer = #{voter_status := _}} ->
{Self, Peer = #{voter_status := VoterStatus}} ->
%% For completeness sake, preserve `target`
%% of once promoted leader.
#{next_index => CI+1,
match_index => CI,
query_index => QI,
status => normal,
voter_status => Peer#{membership => Membership}};
match_index => CI,
query_index => QI,
status => normal,
voter_status => VoterStatus#{membership => Membership}};
{Self, _} ->
#{next_index => CI+1,
match_index => CI,
query_index => QI,
status => normal,
voter_status => #{membership => Membership}};
match_index => CI,
query_index => QI,
status => normal,
voter_status => #{membership => Membership}};
{_, Peer = #{voter_status := _}} ->
Peer;
{_, Peer} ->
Expand All @@ -1578,8 +1584,8 @@ do_state_query(members_info, #{cfg := #cfg{id = Self}, cluster := Cluster,
end
end, Cluster);
do_state_query(members_info, #{cfg := #cfg{id = Self}, cluster := Cluster,
query_index := QI, commit_index := CI,
membership := Membership}) ->
query_index := QI, commit_index := CI,
membership := Membership}) ->
%% Followers do not have sufficient information,
%% bail out and send whatever we have.
maps:map(fun(Id, Peer) ->
Expand Down

0 comments on commit 7944515

Please sign in to comment.