Skip to content

Commit

Permalink
ra_server_proc: Defer a call to determine_leader/2 to where it's ne…
Browse files Browse the repository at this point in the history
…eded

[Why]
If the query has a condition, the result of the call to
`determine_leader/2` is not used. Furthermore, it is called again by
another function further down the line.
  • Loading branch information
dumbbell committed Jul 25, 2024
1 parent 6aaaaf8 commit c287738
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ra_server_proc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1188,9 +1188,9 @@ perform_or_delay_local_query(
%% If the condition is set to `{applied, {Index, Term}}', the query is
%% added to a list of pending queries. It will be evaluated once that
%% index is applied locally.
Leader = determine_leader(RaftState, State),
case maps:get(condition, Options, undefined) of
undefined ->
Leader = determine_leader(RaftState, State),
Reply = perform_local_query(QueryFun, Leader, ServerState, Conf),
{keep_state, State, [{reply, From, Reply}]};
Condition ->
Expand Down

0 comments on commit c287738

Please sign in to comment.