Skip to content
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
15 changes: 14 additions & 1 deletion deps/rabbit/src/rabbit_amqqueue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
-export([internal_declare/2, internal_delete/2, run_backing_queue/3,
emit_consumers_local/3, internal_delete/3]).

%% Deprecated feature callback.
-export([are_transient_nonexcl_used/1]).

-include_lib("rabbit_common/include/rabbit.hrl").
-include_lib("stdlib/include/qlc.hrl").
-include("amqqueue.hrl").
Expand Down Expand Up @@ -110,9 +113,19 @@
-rabbit_deprecated_feature(
{transient_nonexcl_queues,
#{deprecation_phase => permitted_by_default,
doc_url => "https://blog.rabbitmq.com/posts/2021/08/4.0-deprecation-announcements/#removal-of-transient-non-exclusive-queues"
doc_url => "https://blog.rabbitmq.com/posts/2021/08/4.0-deprecation-announcements/#removal-of-transient-non-exclusive-queues",
callbacks => #{is_feature_used => {?MODULE, are_transient_nonexcl_used}}
}}).

are_transient_nonexcl_used(_) ->
case rabbit_db_queue:list_transient() of
{ok, Queues} ->
NonExclQueues = [Q || Q <- Queues, not is_exclusive(Q)],
length(NonExclQueues) > 0;
{error, _} ->
undefined
end.

-define(CONSUMER_INFO_KEYS,
[queue_name, channel_pid, consumer_tag, ack_required, prefetch_count,
active, activity_status, arguments]).
Expand Down
37 changes: 36 additions & 1 deletion deps/rabbit/src/rabbit_db_queue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@

%% Used by on_node_up and on_node_down.
%% Can be deleted once transient entities/mnesia are removed.
-export([foreach_transient/1,
-export([list_transient/0,
foreach_transient/1,
delete_transient/1]).

%% Only used by rabbit_amqqueue:forget_node_for_queue, which is only called
Expand Down Expand Up @@ -965,6 +966,40 @@ set_in_khepri(Q) ->
Path = khepri_queue_path(amqqueue:get_name(Q)),
rabbit_khepri:put(Path, Q).

%% -------------------------------------------------------------------
%% list_transient().
%% -------------------------------------------------------------------

-spec list_transient() -> {ok, Queues} | {error, any()} when
Queues :: [amqqueue:amqqueue()].
%% @doc Applies `UpdateFun' to all transient queue records.
%%
%% @private

list_transient() ->
rabbit_khepri:handle_fallback(
#{mnesia => fun() -> list_transient_in_mnesia() end,
khepri => fun() -> list_transient_in_khepri() end
}).

list_transient_in_mnesia() ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the late comment, but to me it looks like if mnesia is used, this will list all queues, not just transient ones.
I get a "Deprecated features are being used" "transient_nonexcl_queues | In use Permitted by default" warning when I have a single durable quorum queue.

> rabbit_db_queue:list_transient().
{ok,[#amqqueue{name = #resource{virtual_host = <<"/">>,
                                kind = queue,name = <<"qq1">>},
               durable = true,auto_delete = false,exclusive_owner = none,
               ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then there is a long-standing bug in this function. Could you please file an issue for it? I can’t work on this one right now.

Pattern = amqqueue:pattern_match_all(),
AllQueues = mnesia:dirty_match_object(
?MNESIA_TABLE,
Pattern),
{ok, AllQueues}.

list_transient_in_khepri() ->
try
List = ets:match_object(
?KHEPRI_PROJECTION,
amqqueue:pattern_match_on_durable(false)),
{ok, List}
catch
error:badarg ->
{error, {khepri_projection_missing, ?KHEPRI_WILDCARD_STAR}}
end.

%% -------------------------------------------------------------------
%% delete_transient().
%% -------------------------------------------------------------------
Expand Down
Loading