Skip to content

Commit 3ecb3b6

Browse files
Ayanda-Dmichaelklishin
authored andcommitted
Use whereis/1 instead of rabbit_process helper, and lists:filtermap/2 in
rabbit_quorum_queue:all_replica_states/0 (cherry picked from commit 19cc2d0)
1 parent 6bb4c89 commit 3ecb3b6

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

deps/rabbit/src/rabbit_quorum_queue.erl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -441,18 +441,19 @@ become_leader0(QName, Name) ->
441441
-spec all_replica_states() -> {node(), #{atom() => atom()}}.
442442
all_replica_states() ->
443443
Rows0 = ets:tab2list(ra_state),
444-
Rows = lists:map(fun
444+
Rows = lists:filtermap(
445+
fun
445446
(T = {K, _, _}) ->
446-
case rabbit_process:is_registered_process_alive(K) of
447-
true ->
448-
to_replica_state(T);
449-
false ->
450-
[]
447+
case whereis(K) of
448+
undefined ->
449+
false;
450+
P when is_pid(P) ->
451+
{true, to_replica_state(T)}
451452
end;
452453
(_T) ->
453-
[]
454-
end, Rows0),
455-
{node(), maps:from_list(lists:flatten(Rows))}.
454+
false
455+
end, Rows0),
456+
{node(), maps:from_list(Rows)}.
456457

457458
to_replica_state({K, follower, promotable}) ->
458459
{K, promotable};

0 commit comments

Comments
 (0)