Skip to content

Commit 9070e39

Browse files
Ayanda-Dmichaelklishin
authored andcommitted
Ensure only alive QQ replica states are reported
when checking replica states to help avoid missing inactive replicas e.g. on QQ checks from cli tools (cherry picked from commit 4914850)
1 parent d5063c7 commit 9070e39

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

deps/rabbit/src/rabbit_quorum_queue.erl

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -442,17 +442,25 @@ become_leader0(QName, Name) ->
442442
all_replica_states() ->
443443
Rows0 = ets:tab2list(ra_state),
444444
Rows = lists:map(fun
445-
({K, follower, promotable}) ->
446-
{K, promotable};
447-
({K, follower, non_voter}) ->
448-
{K, non_voter};
449-
({K, S, _}) ->
450-
%% voter or unknown
451-
{K, S};
452-
(T) ->
453-
T
445+
(T = {K, _, _}) ->
446+
case rabbit_process:is_registered_process_alive(K) of
447+
true ->
448+
to_replica_state(T);
449+
false ->
450+
[]
451+
end;
452+
(_T) ->
453+
[]
454454
end, Rows0),
455-
{node(), maps:from_list(Rows)}.
455+
{node(), maps:from_list(lists:flatten(Rows))}.
456+
457+
to_replica_state({K, follower, promotable}) ->
458+
{K, promotable};
459+
to_replica_state({K, follower, non_voter}) ->
460+
{K, non_voter};
461+
to_replica_state({K, S, _}) ->
462+
%% voter or unknown
463+
{K, S}.
456464

457465
-spec list_with_minimum_quorum() -> [amqqueue:amqqueue()].
458466
list_with_minimum_quorum() ->

0 commit comments

Comments
 (0)