Skip to content

Commit 90b5530

Browse files
Merge pull request #15007 from rabbitmq/mergify/bp/v4.2.x/pr-15003
Handle crashed member in quorum queue status (backport #15003)
2 parents 980a6ce + 3292c00 commit 90b5530

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

deps/rabbit/src/rabbit_quorum_queue.erl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,20 @@ status(Vhost, QueueName) ->
12811281
{<<"Term">>, Term},
12821282
{<<"Machine Version">>, MacVer}
12831283
];
1284+
#{state := noproc,
1285+
membership := unknown,
1286+
machine_version := MacVer} ->
1287+
[{<<"Node Name">>, N},
1288+
{<<"Raft State">>, noproc},
1289+
{<<"Membership">>, <<>>},
1290+
{<<"Last Log Index">>, <<>>},
1291+
{<<"Last Written">>, <<>>},
1292+
{<<"Last Applied">>, <<>>},
1293+
{<<"Commit Index">>, <<>>},
1294+
{<<"Snapshot Index">>, <<>>},
1295+
{<<"Term">>, <<>>},
1296+
{<<"Machine Version">>, MacVer}
1297+
];
12841298
{error, _} ->
12851299
%% try the old method
12861300
case get_sys_status(ServerId) of
@@ -1309,7 +1323,7 @@ status(Vhost, QueueName) ->
13091323
[{<<"Node Name">>, N},
13101324
{<<"Raft State">>, Err},
13111325
{<<"Membership">>, <<>>},
1312-
{<<"LastLog Index">>, <<>>},
1326+
{<<"Last Log Index">>, <<>>},
13131327
{<<"Last Written">>, <<>>},
13141328
{<<"Last Applied">>, <<>>},
13151329
{<<"Commit Index">>, <<>>},

deps/rabbit/test/quorum_queue_SUITE.erl

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ groups() ->
9292
leader_locator_balanced_random_maintenance,
9393
leader_locator_policy,
9494
status,
95+
status_noproc,
9596
format,
9697
add_member_2,
9798
single_active_consumer_priority_take_over,
@@ -4050,9 +4051,9 @@ oldest_entry_timestamp(Config) ->
40504051

40514052
ok.
40524053

4053-
-define(STATUS_MATCH(N, T),
4054+
-define(STATUS_MATCH(N, RS, T),
40544055
[{<<"Node Name">>, N},
4055-
{<<"Raft State">>, _},
4056+
{<<"Raft State">>, RS},
40564057
{<<"Membership">>, _},
40574058
{<<"Last Log Index">>, _},
40584059
{<<"Last Written">>, _},
@@ -4083,9 +4084,9 @@ status(Config) ->
40834084

40844085
%% check that nodes are returned and that at least the term isn't
40854086
%% defaulted (i.e. there was an error)
4086-
?assertMatch([?STATUS_MATCH(N1, T1),
4087-
?STATUS_MATCH(N2, T2),
4088-
?STATUS_MATCH(N3, T3)
4087+
?assertMatch([?STATUS_MATCH(N1, _, T1),
4088+
?STATUS_MATCH(N2, _, T2),
4089+
?STATUS_MATCH(N3, _, T3)
40894090
] when T1 /= <<>> andalso
40904091
T2 /= <<>> andalso
40914092
T3 /= <<>>,
@@ -4094,6 +4095,34 @@ status(Config) ->
40944095
wait_for_messages(Config, [[QQ, <<"2">>, <<"2">>, <<"0">>]]),
40954096
ok.
40964097

4098+
status_noproc(Config) ->
4099+
Nodes = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
4100+
[N1, N2, N3] = lists:sort(Nodes),
4101+
4102+
Ch = rabbit_ct_client_helpers:open_channel(Config, N1),
4103+
4104+
QQ = ?config(queue_name, Config),
4105+
RaName = ra_name(QQ),
4106+
?assertEqual({'queue.declare_ok', QQ, 0, 0},
4107+
declare(Ch, QQ, [{<<"x-queue-type">>, longstr, <<"quorum">>}])),
4108+
4109+
ensure_qq_proc_dead(Config, N1, RaName),
4110+
%% simulate that the queue member terminated so early that it
4111+
%% hasn't recorded any counters yet
4112+
rabbit_ct_broker_helpers:rpc(Config, N1, ra_counters, delete, [{RaName, N1}]),
4113+
4114+
%% check that some status is returned for each node
4115+
?assertMatch([?STATUS_MATCH(N1, noproc, T1),
4116+
?STATUS_MATCH(N2, RS2, T2),
4117+
?STATUS_MATCH(N3, RS3, T3)
4118+
] when T1 == <<>> andalso
4119+
T2 /= <<>> andalso
4120+
T3 /= <<>> andalso
4121+
(RS2 == leader orelse RS2 == follower) andalso
4122+
(RS3 == leader orelse RS3 == follower),
4123+
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_quorum_queue,
4124+
status, [<<"/">>, QQ])),
4125+
ok.
40974126
format(Config) ->
40984127
%% tests rabbit_quorum_queue:format/2
40994128
Nodes = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),

0 commit comments

Comments
 (0)