Skip to content

Do not show queues with deleted vhost. #1301

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 1 commit into from
Jul 21, 2017
Merged
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
47 changes: 39 additions & 8 deletions src/rabbit_amqqueue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ recover() ->
%% Clear out remnants of old incarnation, in case we restarted
%% faster than other nodes handled DOWN messages from us.
on_node_down(node()),
DurableQueues = find_durable_queues(),
DurableQueues = queues_to_recover(),

L = length(DurableQueues),

%% if there are not enough file handles, the server might hang
Expand Down Expand Up @@ -257,6 +258,31 @@ start(Qs) ->
[Pid ! {self(), go} || #amqqueue{pid = Pid} <- Qs],
ok.

queues_to_recover() ->
DurableQueues = find_durable_queues(),
VHosts = rabbit_vhost:list(),

{QueuesWithVhost, QueuesWithoutVhost} = lists:partition(
fun(#amqqueue{name = #resource{virtual_host = VHost}}) ->
lists:member(VHost, VHosts)
end,
DurableQueues),

{LocalQueuesWithoutVhost, _RemoteQueuesWithoutVhost} = lists:partition(
fun(#amqqueue{pid = QPid}) -> node(QPid) == node() end,
QueuesWithoutVhost),

{atomic, ok} =
mnesia:sync_transaction(
fun () ->
rabbit_log:error("Deleting ~p~n", [LocalQueuesWithoutVhost]),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be info rather than error?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd make it a warning and explain why it's being deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was a debug message. Do you think it should stay?

[ internal_delete1(Name, false)
|| #amqqueue{name = Name} <- LocalQueuesWithoutVhost ],
ok
end),

QueuesWithVhost.

find_durable_queues() ->
Node = node(),
mnesia:async_dirty(
Expand Down Expand Up @@ -576,7 +602,8 @@ list_local_names() ->
State =/= crashed,
node() =:= node(QPid) ].

list(VHostPath) -> list(VHostPath, rabbit_queue).
list(VHostPath) ->
list(VHostPath, rabbit_queue).

%% Not dirty_match_object since that would not be transactional when used in a
%% tx context
Expand All @@ -590,12 +617,16 @@ list(VHostPath, TableName) ->
end).

list_down(VHostPath) ->
Present = list(VHostPath),
Durable = list(VHostPath, rabbit_durable_queue),
PresentS = sets:from_list([N || #amqqueue{name = N} <- Present]),
sets:to_list(sets:filter(fun (#amqqueue{name = N}) ->
not sets:is_element(N, PresentS)
end, sets:from_list(Durable))).
case rabbit_vhost:exists(VHostPath) of
false -> [];
true ->
Present = list(VHostPath),
Durable = list(VHostPath, rabbit_durable_queue),
PresentS = sets:from_list([N || #amqqueue{name = N} <- Present]),
sets:to_list(sets:filter(fun (#amqqueue{name = N}) ->
not sets:is_element(N, PresentS)
end, sets:from_list(Durable)))
end.

info_keys() -> rabbit_amqqueue_process:info_keys().

Expand Down