Skip to content

Commit

Permalink
Update QQ force-shrink logging
Browse files Browse the repository at this point in the history
(cherry picked from commit dd5ec3c)
  • Loading branch information
Ayanda-D authored and michaelklishin committed Oct 7, 2024
1 parent c9d97e6 commit 16170d0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions deps/rabbit/src/rabbit_quorum_queue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1953,9 +1953,10 @@ notify_decorators(QName, F, A) ->
is_stateful() -> true.

force_shrink_member_to_current_member(VHost, Name) ->
rabbit_log:warning("Disaster recovery procedure: shrinking ~p queue at vhost ~p to a single node cluster", [Name, VHost]),
Node = node(),
QName = rabbit_misc:r(VHost, queue, Name),
QNameFmt = rabbit_misc:rs(QName),
rabbit_log:warning("Shrinking ~ts to a single node: ~ts", [QNameFmt, Node]),
case rabbit_amqqueue:lookup(QName) of
{ok, Q} when ?is_amqqueue(Q) ->
{RaName, _} = amqqueue:get_pid(Q),
Expand All @@ -1968,19 +1969,19 @@ force_shrink_member_to_current_member(VHost, Name) ->
end,
_ = rabbit_amqqueue:update(QName, Fun),
_ = [ra:force_delete_server(?RA_SYSTEM, {RaName, N}) || N <- OtherNodes],
rabbit_log:warning("Disaster recovery procedure: shrinking finished");
rabbit_log:warning("Shrinking ~ts finished", [QNameFmt]);
_ ->
rabbit_log:warning("Disaster recovery procedure: shrinking failed, queue ~p not found at vhost ~p", [Name, VHost]),
rabbit_log:warning("Shrinking failed, ~ts not found", [QNameFmt]),
{error, not_found}
end.

force_vhost_queues_shrink_member_to_current_member(VHost) when is_binary(VHost) ->
rabbit_log:warning("Disaster recovery procedure: shrinking all quorum queues in vhost ~tp to a single node cluster", [VHost]),
rabbit_log:warning("Shrinking all quorum queues in vhost '~ts' to a single node: ~ts", [VHost, node()]),
ListQQs = fun() -> rabbit_amqqueue:list(VHost) end,
force_all_queues_shrink_member_to_current_member(ListQQs).

force_all_queues_shrink_member_to_current_member() ->
rabbit_log:warning("Disaster recovery procedure: shrinking all quorum queues to a single node cluster"),
rabbit_log:warning("Shrinking all quorum queues to a single node: ~ts", [node()]),
ListQQs = fun() -> rabbit_amqqueue:list() end,
force_all_queues_shrink_member_to_current_member(ListQQs).

Expand All @@ -1990,7 +1991,7 @@ force_all_queues_shrink_member_to_current_member(ListQQFun) when is_function(Lis
QName = amqqueue:get_name(Q),
{RaName, _} = amqqueue:get_pid(Q),
OtherNodes = lists:delete(Node, get_nodes(Q)),
rabbit_log:warning("Disaster recovery procedure: shrinking queue ~p", [QName]),
rabbit_log:warning("Shrinking queue ~ts to a single node: ~ts", [rabbit_misc:rs(QName), Node]),
ok = ra_server_proc:force_shrink_members_to_current_member({RaName, Node}),
Fun = fun (QQ) ->
TS0 = amqqueue:get_type_state(QQ),
Expand All @@ -2000,7 +2001,7 @@ force_all_queues_shrink_member_to_current_member(ListQQFun) when is_function(Lis
_ = rabbit_amqqueue:update(QName, Fun),
_ = [ra:force_delete_server(?RA_SYSTEM, {RaName, N}) || N <- OtherNodes]
end || Q <- ListQQFun(), amqqueue:get_type(Q) == ?MODULE],
rabbit_log:warning("Disaster recovery procedure: shrinking finished"),
rabbit_log:warning("Shrinking finished"),
ok.

is_minority(All, Up) ->
Expand Down

0 comments on commit 16170d0

Please sign in to comment.