From eb91d50fd4632ceeb68ab14ef8886331c65d2b09 Mon Sep 17 00:00:00 2001 From: kjnilsson Date: Tue, 16 Mar 2021 09:01:56 +0000 Subject: stream coordinator fall back to consistent query --- deps/rabbit/src/rabbit_stream_coordinator.erl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/deps/rabbit/src/rabbit_stream_coordinator.erl b/deps/rabbit/src/rabbit_stream_coordinator.erl index 24df463ab6..0db22327bf 100644 --- a/deps/rabbit/src/rabbit_stream_coordinator.erl +++ b/deps/rabbit/src/rabbit_stream_coordinator.erl @@ -183,6 +183,18 @@ local_pid(StreamId) when is_list(StreamId) -> members(StreamId) when is_list(StreamId) -> MFA = {?MODULE, query_members, [StreamId]}, case ra:local_query({?MODULE, node()}, MFA) of + {ok, {_, {ok, _} = Result}, _} -> + Result; + {ok, {_, {error, not_found} = Result}, _} -> + %% fall back to consistent query + case ra:consistent_query({?MODULE, node()}, MFA) of + {ok, Result, _} -> + Result; + {error, _} = Err -> + Err; + {timeout, _} -> + {error, timeout} + end; {ok, {_, Result}, _} -> Result; {error, _} = Err -> -- cgit v1.2.1