WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 5615a2b

Browse files
the-mikedavismergify[bot]
authored andcommitted
rabbit_quorum_queue: Remove old compatibility code in status/2
The `sys:get_status/1` fallback doesn't work as expected since the changes in Ra for OTP 27: <rabbitmq/ra@ab280c7>. This code is meant for mixed-versions compatibility with nodes that don't have the `rabbit_quorum_queue:key_metrics_rpc/1` function which was added in v3.13.0. Quorum queues with a member down could see a failure of the quorum_status CLI command like so: % rabbitmq rabbitmq-queues quorum_status --vhost / "qq-1" Status of quorum queue qq-1 on node [email protected] ... Error: {{:badmatch, false}, [{:rabbit_quorum_queue, :"-status/2-lc$^0/1-0-", 2, [file: ~c"rabbit_quorum_queue.erl", line: 1287]}, {:rabbit_quorum_queue, :status, 2, []}]} The badmatch comes from this line in `rabbit_quorum_queue:status/2`: {_, M} = lists:keyfind(ra_server_state, 1, Sys), The `Sys` return was `[{data, Sys}]` since the linked change in Ra, so the `keyfind/3` would always return `false`. (cherry picked from commit 38f83d7)
1 parent 1d757e7 commit 5615a2b

File tree

1 file changed

+16
-48
lines changed

1 file changed

+16
-48
lines changed

deps/rabbit/src/rabbit_quorum_queue.erl

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,43 +1295,22 @@ status(Vhost, QueueName) ->
12951295
{<<"Term">>, <<>>},
12961296
{<<"Machine Version">>, MacVer}
12971297
];
1298-
{error, _} ->
1299-
%% try the old method
1300-
case get_sys_status(ServerId) of
1301-
{ok, Sys} ->
1302-
{_, M} = lists:keyfind(ra_server_state, 1, Sys),
1303-
{_, RaftState} = lists:keyfind(raft_state, 1, Sys),
1304-
#{commit_index := Commit,
1305-
machine_version := MacVer,
1306-
current_term := Term,
1307-
last_applied := LastApplied,
1308-
log := #{last_index := Last,
1309-
last_written_index_term := {LastWritten, _},
1310-
snapshot_index := SnapIdx}} = M,
1311-
[{<<"Node Name">>, N},
1312-
{<<"Raft State">>, RaftState},
1313-
{<<"Membership">>, voter},
1314-
{<<"Last Log Index">>, Last},
1315-
{<<"Last Written">>, LastWritten},
1316-
{<<"Last Applied">>, LastApplied},
1317-
{<<"Commit Index">>, Commit},
1318-
{<<"Snapshot Index">>, SnapIdx},
1319-
{<<"Term">>, Term},
1320-
{<<"Machine Version">>, MacVer}
1321-
];
1322-
{error, Err} ->
1323-
[{<<"Node Name">>, N},
1324-
{<<"Raft State">>, Err},
1325-
{<<"Membership">>, <<>>},
1326-
{<<"Last Log Index">>, <<>>},
1327-
{<<"Last Written">>, <<>>},
1328-
{<<"Last Applied">>, <<>>},
1329-
{<<"Commit Index">>, <<>>},
1330-
{<<"Snapshot Index">>, <<>>},
1331-
{<<"Term">>, <<>>},
1332-
{<<"Machine Version">>, <<>>}
1333-
]
1334-
end
1298+
{error, Reason} ->
1299+
State = case is_atom(Reason) of
1300+
true -> Reason;
1301+
false -> unknown
1302+
end,
1303+
[{<<"Node Name">>, N},
1304+
{<<"Raft State">>, State},
1305+
{<<"Membership">>, <<>>},
1306+
{<<"Last Log Index">>, <<>>},
1307+
{<<"Last Written">>, <<>>},
1308+
{<<"Last Applied">>, <<>>},
1309+
{<<"Commit Index">>, <<>>},
1310+
{<<"Snapshot Index">>, <<>>},
1311+
{<<"Term">>, <<>>},
1312+
{<<"Machine Version">>, <<>>}
1313+
]
13351314
end
13361315
end || N <- Nodes];
13371316
{ok, _Q} ->
@@ -1340,17 +1319,6 @@ status(Vhost, QueueName) ->
13401319
E
13411320
end.
13421321

1343-
get_sys_status(Proc) ->
1344-
try lists:nth(5, element(4, sys:get_status(Proc))) of
1345-
Sys -> {ok, Sys}
1346-
catch
1347-
_:Err when is_tuple(Err) ->
1348-
{error, element(1, Err)};
1349-
_:_ ->
1350-
{error, other}
1351-
1352-
end.
1353-
13541322
add_member(VHost, Name, Node, Membership, Timeout)
13551323
when is_binary(VHost) andalso
13561324
is_binary(Name) andalso

0 commit comments

Comments
 (0)