Skip to content

CMQ cleanup #11716

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 5 commits into from
Jul 15, 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
32 changes: 0 additions & 32 deletions deps/rabbit/docs/rabbitmqctl.8
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions deps/rabbit/docs/set_rabbitmq_policy.sh.example
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -15,113 +17,37 @@ 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
use RabbitMQ.CLI.Core.MergesNoDefaults
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
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"
}}
def run([], _opts) do
:ok
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
Loading