summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Klishin <michael@novemberain.com>2017-08-10 02:57:55 +0300
committerGitHub <noreply@github.com>2017-08-10 02:57:55 +0300
commitec5ffe7296fbb883dccb35802d4bbcf8f2473e0d (patch)
tree347c86ac2f8170e2750698530cf6c0b4a51673b4 /src
parent2a01b6c6d18c2f29abbfa5fbf88d5de1ac9c43c3 (diff)
parentaf397dd1b42eaf44f7213f847fed6c0135812e20 (diff)
downloadrabbitmq-server-git-ec5ffe7296fbb883dccb35802d4bbcf8f2473e0d.tar.gz
Merge pull request #1325 from rabbitmq/rabbitmq-server-1323
Clean up orphaned exclusive queues
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_amqqueue.erl19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index b4195866ea..467cd998bc 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -34,7 +34,8 @@
-export([notify_down_all/2, notify_down_all/3, activate_limit_all/2, credit/5]).
-export([on_node_up/1, on_node_down/1]).
-export([update/2, store_queue/1, update_decorators/1, policy_changed/2]).
--export([update_mirroring/1, sync_mirrors/1, cancel_sync_mirrors/1, is_mirrored/1]).
+-export([update_mirroring/1, sync_mirrors/1, cancel_sync_mirrors/1]).
+-export([is_mirrored/1, is_dead_exclusive/1]). % Note: exported due to use in qlc expression.
-export([pid_of/1, pid_of/2]).
@@ -919,6 +920,11 @@ cancel_sync_mirrors(QPid) -> delegate:call(QPid, cancel_sync_mi
is_mirrored(Q) ->
rabbit_mirror_queue_misc:is_mirrored(Q).
+is_dead_exclusive(#amqqueue{exclusive_owner = none}) ->
+ false;
+is_dead_exclusive(#amqqueue{exclusive_owner = Pid}) when is_pid(Pid) ->
+ not rabbit_mnesia:is_process_alive(Pid).
+
on_node_up(Node) ->
ok = rabbit_misc:execute_mnesia_transaction(
fun () ->
@@ -963,11 +969,12 @@ on_node_down(Node) ->
rabbit_misc:execute_mnesia_tx_with_tail(
fun () -> QsDels =
qlc:e(qlc:q([{QName, delete_queue(QName)} ||
- #amqqueue{name = QName, pid = Pid} = Q
- <- mnesia:table(rabbit_queue),
- not rabbit_amqqueue:is_mirrored(Q) andalso
- node(Pid) == Node andalso
- not rabbit_mnesia:is_process_alive(Pid)])),
+ #amqqueue{name = QName, pid = Pid} =
+ Q <- mnesia:table(rabbit_queue),
+ node(Pid) == Node andalso
+ not rabbit_mnesia:is_process_alive(Pid) andalso
+ (not rabbit_amqqueue:is_mirrored(Q) orelse
+ rabbit_amqqueue:is_dead_exclusive(Q))])),
{Qs, Dels} = lists:unzip(QsDels),
T = rabbit_binding:process_deletions(
lists:foldl(fun rabbit_binding:combine_deletions/2,