From 26b0259a99bc778a38a1346417579ec13f3d7499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Mon, 1 Jul 2024 15:57:12 +0200 Subject: [PATCH] Emit the new `local_query` tuple only if query options are set [Why] Using the new tuple isn't compatible with older versions of Ra. This breaks local/leader queries if there are Ra members running an old version. [How] We don't need the new `{local_query, QueryFun, Options}` tuple if there is no options. We can use the old `{local_query, QueryFun}` in this case and keep the compatibility. --- src/ra_server_proc.erl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ra_server_proc.erl b/src/ra_server_proc.erl index d039310c..23fbc001 100644 --- a/src/ra_server_proc.erl +++ b/src/ra_server_proc.erl @@ -180,8 +180,14 @@ cast_command(ServerId, Priority, Cmd) -> ra_server_proc:ra_leader_call_ret({ra_idxterm(), Reply :: term()}) | ra_server_proc:ra_leader_call_ret(Reply :: term()) | {ok, {ra_idxterm(), Reply :: term()}, not_known}. +query(ServerLoc, QueryFun, local, Options, Timeout) + when map_size(Options) =:= 0 -> + statem_call(ServerLoc, {local_query, QueryFun}, Timeout); query(ServerLoc, QueryFun, local, Options, Timeout) -> statem_call(ServerLoc, {local_query, QueryFun, Options}, Timeout); +query(ServerLoc, QueryFun, leader, Options, Timeout) + when map_size(Options) =:= 0 -> + leader_call(ServerLoc, {local_query, QueryFun}, Timeout); query(ServerLoc, QueryFun, leader, Options, Timeout) -> leader_call(ServerLoc, {local_query, QueryFun, Options}, Timeout); query(ServerLoc, QueryFun, consistent, _Options, Timeout) ->