Merge pull request #11716 from rabbitmq/cmq-cleanup

CMQ cleanup
This commit is contained in:
Michael Klishin 2024-07-15 13:39:09 -04:00 committed by GitHub
commit ff5a324564
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 119 deletions

View File

@ -463,38 +463,6 @@ is part of, as a ram node:
To learn more, see the To learn more, see the
.Lk https://www.rabbitmq.com/clustering.html "RabbitMQ Clustering guide". .Lk https://www.rabbitmq.com/clustering.html "RabbitMQ Clustering guide".
.\" ------------------------------------------------------------------ .\" ------------------------------------------------------------------
.\" ## Classic Mirrored Queues
.\" ------------------------------------------------------------------
.Ss Replication
.Bl -tag -width Ds
.\" ------------------------------------------------------------------
.It Cm sync_queue Oo Fl p Ar vhost Oc Ar queue
.Bl -tag -width Ds
.It Ar queue
The name of the queue to synchronise.
.El
.Pp
Instructs a mirrored queue with unsynchronised mirrors (follower replicas)
to synchronise them.
The queue will block while synchronisation takes place (all publishers
and consumers using the queue will block or temporarily see no activity).
This command can only be used with mirrored queues.
To learn more, see the
.Lk https://www.rabbitmq.com/ha.html "RabbitMQ Classic Queue Mirroring guide"
.Pp
Note that queues with unsynchronised replicas and active consumers
will become synchronised eventually (assuming that consumers make progress).
This command is primarily useful for queues that do not have active consumers.
.\" ------------------------------------------------------------------
.It Cm cancel_sync_queue Oo Fl p Ar vhost Oc Ar queue
.Bl -tag -width Ds
.It Ar queue
The name of the queue to cancel synchronisation for.
.El
.Pp
Instructs a synchronising mirrored queue to stop synchronising itself.
.El
.\" ------------------------------------------------------------------
.\" ## User management .\" ## User management
.\" ------------------------------------------------------------------ .\" ------------------------------------------------------------------
.Ss User Management .Ss User Management

View File

@ -1,4 +1,3 @@
# This script is called by rabbitmq-server-ha.ocf during RabbitMQ # This script is called by rabbitmq-server-ha.ocf during RabbitMQ
# cluster start up. It is a convenient place to set your cluster # cluster start up. It is a convenient place to set your cluster
# policy here, for example: # policy here. See https://www.rabbitmq.com/docs/parameters for examples
# ${OCF_RESKEY_ctl} set_policy ha-all "." '{"ha-mode":"all", "ha-sync-mode":"automatic"}' --apply-to all --priority 0

View File

@ -6,6 +6,8 @@
defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsMirrorSyncCriticalCommand do defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsMirrorSyncCriticalCommand do
@moduledoc """ @moduledoc """
DEPRECATED: this command does nothing in RabbitMQ 4.0 and newer.
Exits with a non-zero code if there are classic mirrored queues that don't Exits with a non-zero code if there are classic mirrored queues that don't
have any in sync mirrors online and would potentially lose data have any in sync mirrors online and would potentially lose data
if the target node is shut down. if the target node is shut down.
@ -15,8 +17,6 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsMirrorSyncCriticalCommand do
@behaviour RabbitMQ.CLI.CommandBehaviour @behaviour RabbitMQ.CLI.CommandBehaviour
import RabbitMQ.CLI.Core.Platform, only: [line_separator: 0]
def scopes(), do: [:diagnostics, :queues] def scopes(), do: [:diagnostics, :queues]
use RabbitMQ.CLI.Core.AcceptsDefaultSwitchesAndTimeout use RabbitMQ.CLI.Core.AcceptsDefaultSwitchesAndTimeout
@ -24,104 +24,30 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsMirrorSyncCriticalCommand do
use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
def run([], %{node: node_name, timeout: timeout}) do def run([], _opts) do
case :rabbit_misc.rpc_call(node_name, :rabbit_nodes, :is_single_node_cluster, [], timeout) do :ok
# if target node is the only one in the cluster, the check makes little sense
# and false positives can be misleading
true ->
{:ok, :single_node_cluster}
false ->
case :rabbit_misc.rpc_call(
node_name,
:rabbit_amqqueue,
:list_local_mirrored_classic_without_synchronised_mirrors_for_cli,
[],
timeout
) do
[] -> {:ok, []}
qs when is_list(qs) -> {:ok, qs}
other -> other
end
other ->
other
end
end end
def output({:ok, :single_node_cluster}, %{formatter: "json"}) do def output(:ok, %{formatter: "json"}) do
{:ok,
%{
"result" => "ok",
"message" =>
"Target node seems to be the only one in a single node cluster, the check does not apply"
}}
end
def output({:ok, []}, %{formatter: "json"}) do
{:ok, %{"result" => "ok"}} {:ok, %{"result" => "ok"}}
end end
def output({:ok, :single_node_cluster}, %{silent: true}) do def output(:ok, _opts) do
{:ok, :check_passed} {:ok, "ok"}
end
def output({:ok, []}, %{silent: true}) do
{:ok, :check_passed}
end
def output({:ok, :single_node_cluster}, %{node: node_name}) do
{:ok,
"Node #{node_name} seems to be the only one in a single node cluster, the check does not apply"}
end
def output({:ok, []}, %{node: node_name}) do
{:ok,
"Node #{node_name} reported no classic mirrored queues without online synchronised mirrors"}
end
def output({:ok, qs}, %{node: node_name, formatter: "json"}) when is_list(qs) do
{:error, :check_failed,
%{
"result" => "error",
"queues" => qs,
"message" =>
"Node #{node_name} reported local classic mirrored queues without online synchronised mirrors"
}}
end
def output({:ok, qs}, %{silent: true}) when is_list(qs) do
{:error, :check_failed}
end
def output({:ok, qs}, %{node: node_name}) when is_list(qs) do
lines = queue_lines(qs, node_name)
{:error, :check_failed, Enum.join(lines, line_separator())}
end end
use RabbitMQ.CLI.DefaultOutput use RabbitMQ.CLI.DefaultOutput
def help_section(), do: :observability_and_health_checks def help_section(), do: :deprecated
def description() do def description() do
"Health check that exits with a non-zero code if there are classic mirrored queues " <> "DEPRECATED. Mirrored queues were removed in RabbitMQ 4.0. This command is a no-op."
"without online synchronised mirrors (queues that would potentially lose data if the target node is shut down)"
end end
def usage, do: "check_if_node_is_mirror_sync_critical" def usage, do: "check_if_node_is_mirror_sync_critical"
def banner([], %{node: node_name}) do def banner([], _) do
"Checking if node #{node_name} is critical for data safety of any classic mirrored queues ..." "This command is DEPRECATED and is a no-op. It will be removed in a future version."
end end
#
# Implementation
#
def queue_lines(qs, node_name) do
for q <- qs do
"#{q["readable_name"]} would lose its only synchronised replica (master) if node #{node_name} is stopped"
end
end
end end