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
.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
.\" ------------------------------------------------------------------
.Ss User Management

View File

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

View File

@ -6,6 +6,8 @@
defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsMirrorSyncCriticalCommand do
@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
have any in sync mirrors online and would potentially lose data
if the target node is shut down.
@ -15,8 +17,6 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsMirrorSyncCriticalCommand do
@behaviour RabbitMQ.CLI.CommandBehaviour
import RabbitMQ.CLI.Core.Platform, only: [line_separator: 0]
def scopes(), do: [:diagnostics, :queues]
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.RequiresRabbitAppRunning
def run([], %{node: node_name, timeout: timeout}) do
case :rabbit_misc.rpc_call(node_name, :rabbit_nodes, :is_single_node_cluster, [], timeout) do
# 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
def run([], _opts) do
:ok
end
def output({:ok, :single_node_cluster}, %{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
def output(:ok, %{formatter: "json"}) do
{:ok, %{"result" => "ok"}}
end
def output({:ok, :single_node_cluster}, %{silent: true}) do
{:ok, :check_passed}
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())}
def output(:ok, _opts) do
{:ok, "ok"}
end
use RabbitMQ.CLI.DefaultOutput
def help_section(), do: :observability_and_health_checks
def help_section(), do: :deprecated
def description() do
"Health check that exits with a non-zero code if there are classic mirrored queues " <>
"without online synchronised mirrors (queues that would potentially lose data if the target node is shut down)"
"DEPRECATED. Mirrored queues were removed in RabbitMQ 4.0. This command is a no-op."
end
def usage, do: "check_if_node_is_mirror_sync_critical"
def banner([], %{node: node_name}) do
"Checking if node #{node_name} is critical for data safety of any classic mirrored queues ..."
def banner([], _) do
"This command is DEPRECATED and is a no-op. It will be removed in a future version."
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