diff options
author | Michael Klishin <michaelklishin@me.com> | 2022-08-05 23:17:50 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-05 23:17:50 +0400 |
commit | 5bbdbb021d6a75dfc27322733412a345156dcd8e (patch) | |
tree | ee5e3a7a966cf09e30b1b484a5a10471a6e65682 | |
parent | b48955043eb8a970736f58a129486966893144f4 (diff) | |
parent | 110899b2548bd4dbf0888333a26268f4145e3f38 (diff) | |
download | rabbitmq-server-git-5bbdbb021d6a75dfc27322733412a345156dcd8e.tar.gz |
Merge pull request #5453 from rabbitmq/mergify/bp/v3.11.x/pr-4563
-rw-r--r-- | deps/rabbit/src/rabbit_amqqueue.erl | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/deps/rabbit/src/rabbit_amqqueue.erl b/deps/rabbit/src/rabbit_amqqueue.erl index 4d60a4d514..bbc4be0042 100644 --- a/deps/rabbit/src/rabbit_amqqueue.erl +++ b/deps/rabbit/src/rabbit_amqqueue.erl @@ -1102,7 +1102,13 @@ list() -> list_with_possible_retry(fun do_list/0). do_list() -> - mnesia:dirty_match_object(rabbit_queue, amqqueue:pattern_match_all()). + All = mnesia:dirty_match_object(rabbit_queue, amqqueue:pattern_match_all()), + NodesRunning = rabbit_nodes:all_running(), + lists:filter(fun (Q) -> + Pid = amqqueue:get_pid(Q), + St = amqqueue:get_state(Q), + St =/= stopped orelse lists:member(node(Pid), NodesRunning) + end, All). -spec count() -> non_neg_integer(). @@ -1282,7 +1288,13 @@ is_in_virtual_host(Q, VHostName) -> -spec list(vhost:name()) -> [amqqueue:amqqueue()]. list(VHostPath) -> - list(VHostPath, rabbit_queue). + All = list(VHostPath, rabbit_queue), + NodesRunning = rabbit_nodes:all_running(), + lists:filter(fun (Q) -> + Pid = amqqueue:get_pid(Q), + St = amqqueue:get_state(Q), + St =/= stopped orelse lists:member(node(Pid), NodesRunning) + end, All). list(VHostPath, TableName) -> list_with_possible_retry(fun() -> do_list(VHostPath, TableName) end). @@ -1336,13 +1348,17 @@ list_down(VHostPath) -> case rabbit_vhost:exists(VHostPath) of false -> []; true -> - Present = list(VHostPath), + Alive = sets:from_list([amqqueue:get_name(Q) || Q <- list(VHostPath)]), Durable = list(VHostPath, rabbit_durable_queue), - PresentS = sets:from_list([amqqueue:get_name(Q) || Q <- Present]), - sets:to_list(sets:filter(fun (Q) -> - N = amqqueue:get_name(Q), - not sets:is_element(N, PresentS) - end, sets:from_list(Durable))) + NodesRunning = rabbit_nodes:all_running(), + lists:filter(fun (Q) -> + N = amqqueue:get_name(Q), + Pid = amqqueue:get_pid(Q), + St = amqqueue:get_state(Q), + (St =:= stopped andalso not lists:member(node(Pid), NodesRunning)) + orelse + (not sets:is_element(N, Alive)) + end, Durable) end. count(VHost) -> @@ -2036,6 +2052,7 @@ queues_to_delete_when_node_down(NodeDown) -> Q <- mnesia:table(rabbit_queue), amqqueue:qnode(Q) == NodeDown andalso not rabbit_mnesia:is_process_alive(amqqueue:get_pid(Q)) andalso + (not amqqueue:is_classic(Q) orelse not amqqueue:is_durable(Q)) andalso (not rabbit_amqqueue:is_replicated(Q) orelse rabbit_amqqueue:is_dead_exclusive(Q))] )) |