Skip to content

Commit 0e38285

Browse files
Merge pull request #15003 from cloudamqp/qq_status_noproc
Handle crashed member in quorum queue status
2 parents 5d600fd + 2a4b6bd commit 0e38285

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
@@ -1276,6 +1276,20 @@ status(Vhost, QueueName) ->
12761276
{<<"Term">>, Term},
12771277
{<<"Machine Version">>, MacVer}
12781278
];
1279+
#{state := noproc,
1280+
membership := unknown,
1281+
machine_version := MacVer} ->
1282+
[{<<"Node Name">>, N},
1283+
{<<"Raft State">>, noproc},
1284+
{<<"Membership">>, <<>>},
1285+
{<<"Last Log Index">>, <<>>},
1286+
{<<"Last Written">>, <<>>},
1287+
{<<"Last Applied">>, <<>>},
1288+
{<<"Commit Index">>, <<>>},
1289+
{<<"Snapshot Index">>, <<>>},
1290+
{<<"Term">>, <<>>},
1291+
{<<"Machine Version">>, MacVer}
1292+
];
12791293
{error, _} ->
12801294
%% try the old method
12811295
case get_sys_status(ServerId) of
@@ -1304,7 +1318,7 @@ status(Vhost, QueueName) ->
13041318
[{<<"Node Name">>, N},
13051319
{<<"Raft State">>, Err},
13061320
{<<"Membership">>, <<>>},
1307-
{<<"LastLog Index">>, <<>>},
1321+
{<<"Last Log Index">>, <<>>},
13081322
{<<"Last Written">>, <<>>},
13091323
{<<"Last Applied">>, <<>>},
13101324
{<<"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,
@@ -4014,9 +4015,9 @@ oldest_entry_timestamp(Config) ->
40144015

40154016
ok.
40164017

4017-
-define(STATUS_MATCH(N, T),
4018+
-define(STATUS_MATCH(N, RS, T),
40184019
[{<<"Node Name">>, N},
4019-
{<<"Raft State">>, _},
4020+
{<<"Raft State">>, RS},
40204021
{<<"Membership">>, _},
40214022
{<<"Last Log Index">>, _},
40224023
{<<"Last Written">>, _},
@@ -4047,9 +4048,9 @@ status(Config) ->
40474048

40484049
%% check that nodes are returned and that at least the term isn't
40494050
%% defaulted (i.e. there was an error)
4050-
?assertMatch([?STATUS_MATCH(N1, T1),
4051-
?STATUS_MATCH(N2, T2),
4052-
?STATUS_MATCH(N3, T3)
4051+
?assertMatch([?STATUS_MATCH(N1, _, T1),
4052+
?STATUS_MATCH(N2, _, T2),
4053+
?STATUS_MATCH(N3, _, T3)
40534054
] when T1 /= <<>> andalso
40544055
T2 /= <<>> andalso
40554056
T3 /= <<>>,
@@ -4058,6 +4059,34 @@ status(Config) ->
40584059
wait_for_messages(Config, [[QQ, <<"2">>, <<"2">>, <<"0">>]]),
40594060
ok.
40604061

4062+
status_noproc(Config) ->
4063+
Nodes = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
4064+
[N1, N2, N3] = lists:sort(Nodes),
4065+
4066+
Ch = rabbit_ct_client_helpers:open_channel(Config, N1),
4067+
4068+
QQ = ?config(queue_name, Config),
4069+
RaName = ra_name(QQ),
4070+
?assertEqual({'queue.declare_ok', QQ, 0, 0},
4071+
declare(Ch, QQ, [{<<"x-queue-type">>, longstr, <<"quorum">>}])),
4072+
4073+
ensure_qq_proc_dead(Config, N1, RaName),
4074+
%% simulate that the queue member terminated so early that it
4075+
%% hasn't recorded any counters yet
4076+
rabbit_ct_broker_helpers:rpc(Config, N1, ra_counters, delete, [{RaName, N1}]),
4077+
4078+
%% check that some status is returned for each node
4079+
?assertMatch([?STATUS_MATCH(N1, noproc, T1),
4080+
?STATUS_MATCH(N2, RS2, T2),
4081+
?STATUS_MATCH(N3, RS3, T3)
4082+
] when T1 == <<>> andalso
4083+
T2 /= <<>> andalso
4084+
T3 /= <<>> andalso
4085+
(RS2 == leader orelse RS2 == follower) andalso
4086+
(RS3 == leader orelse RS3 == follower),
4087+
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_quorum_queue,
4088+
status, [<<"/">>, QQ])),
4089+
ok.
40614090
format(Config) ->
40624091
%% tests rabbit_quorum_queue:format/2
40634092
Nodes = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),

0 commit comments

Comments
 (0)