Skip to content

Fixes to rabbit_maintenance:revive/0 (backport #12026) (backport #12034) #12038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/rabbit/src/rabbit_amqqueue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1304,8 +1304,8 @@ list_local_followers() ->
[Q
|| Q <- list(),
amqqueue:is_quorum(Q),
amqqueue:get_state(Q) =/= crashed,
amqqueue:get_leader(Q) =/= node(),
lists:member(node(), get_quorum_nodes(Q)),
rabbit_quorum_queue:is_recoverable(Q)
].

Expand Down
37 changes: 15 additions & 22 deletions deps/rabbit/src/rabbit_maintenance.erl
Original file line number Diff line number Diff line change
Expand Up @@ -330,28 +330,21 @@ random_nth(Nodes) ->

revive_local_quorum_queue_replicas() ->
Queues = rabbit_amqqueue:list_local_followers(),
[begin
Name = amqqueue:get_name(Q),
rabbit_log:debug("Will trigger a leader election for local quorum queue ~ts",
[rabbit_misc:rs(Name)]),
%% start local QQ replica (Ra server) of this queue
{Prefix, _Node} = amqqueue:get_pid(Q),
RaServer = {Prefix, node()},
rabbit_log:debug("Will start quorum queue replica (Ra server) ~tp", [RaServer]),
case rabbit_quorum_queue:restart_server(RaServer) of
ok ->
rabbit_log:debug("Successfully restarted a quorum queue replica ~tp", [RaServer]);
{error, {already_started, _Pid}} ->
rabbit_log:debug("Quorum queue replica ~tp is already running", [RaServer]);
{error, nodedown} ->
rabbit_log:error("Failed to restart quorum queue replica ~tp: target node was reported as down", [RaServer]);
{error, name_not_registered} ->
rabbit_log:error("Failed to restart quorum queue replica ~tp: it reported as not registered (was deleted very recently?)", [RaServer]);
{error, Other} ->
rabbit_log:error("Failed to restart quorum queue replica ~tp: ~tp", [RaServer, Other])
end
end || Q <- Queues],
rabbit_log:info("Restart of local quorum queue replicas is complete").
%% NB: this function ignores the first argument so we can just pass the
%% empty binary as the vhost name.
{Recovered, Failed} = rabbit_quorum_queue:recover(<<>>, Queues),
rabbit_log:debug("Successfully revived ~b quorum queue replicas",
[length(Recovered)]),
case length(Failed) of
0 ->
ok;
NumFailed ->
rabbit_log:error("Failed to revive ~b quorum queue replicas",
[NumFailed])
end,

rabbit_log:info("Restart of local quorum queue replicas is complete"),
ok.

%%
%% Implementation
Expand Down
1 change: 1 addition & 0 deletions deps/rabbit/test/maintenance_mode_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
-include_lib("eunit/include/eunit.hrl").
-include_lib("rabbitmq_ct_helpers/include/rabbit_assert.hrl").

-compile(nowarn_export_all).
-compile(export_all).

all() ->
Expand Down
Loading