Skip to content

Commit

Permalink
Fix state query leader.
Browse files Browse the repository at this point in the history
The leader_id isn't not guaranteed to be present in the server state
map, hence we cannot pattern match on this as that would return
{error, {unknown_query, leader}} when the expectation is to return
`undefined` whenver the leader is not known.
  • Loading branch information
kjnilsson committed Feb 9, 2024
1 parent 5b949a0 commit d877036
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ra_server_proc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1543,8 +1543,8 @@ do_state_query(voters, #{cluster := Cluster}) ->
end
end, [], Cluster),
Vs;
do_state_query(leader, #{leader_id := Leader}) ->
Leader;
do_state_query(leader, State) ->
maps:get(leader_id, State, undefined);
do_state_query(members, #{cluster := Cluster}) ->
maps:keys(Cluster);
do_state_query(members_info, #{cfg := #cfg{id = Self}, cluster := Cluster,
Expand Down

0 comments on commit d877036

Please sign in to comment.