Skip to content

Commit 793b1af

Browse files
committed
Add is_exclusive to queue deletion clause
1 parent 2a01b6c commit 793b1af

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/rabbit_amqqueue.erl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
-export([notify_down_all/2, notify_down_all/3, activate_limit_all/2, credit/5]).
3535
-export([on_node_up/1, on_node_down/1]).
3636
-export([update/2, store_queue/1, update_decorators/1, policy_changed/2]).
37-
-export([update_mirroring/1, sync_mirrors/1, cancel_sync_mirrors/1, is_mirrored/1]).
37+
-export([update_mirroring/1, sync_mirrors/1, cancel_sync_mirrors/1]).
38+
-export([is_mirrored/1, is_exclusive/1]). % Note: exported due to use in qlc expression.
3839

3940
-export([pid_of/1, pid_of/2]).
4041

@@ -919,6 +920,11 @@ cancel_sync_mirrors(QPid) -> delegate:call(QPid, cancel_sync_mi
919920
is_mirrored(Q) ->
920921
rabbit_mirror_queue_misc:is_mirrored(Q).
921922

923+
is_exclusive(#amqqueue{exclusive_owner = none}) ->
924+
false;
925+
is_exclusive(#amqqueue{exclusive_owner = Pid}) ->
926+
rabbit_mnesia:is_process_alive(Pid).
927+
922928
on_node_up(Node) ->
923929
ok = rabbit_misc:execute_mnesia_transaction(
924930
fun () ->
@@ -963,11 +969,12 @@ on_node_down(Node) ->
963969
rabbit_misc:execute_mnesia_tx_with_tail(
964970
fun () -> QsDels =
965971
qlc:e(qlc:q([{QName, delete_queue(QName)} ||
966-
#amqqueue{name = QName, pid = Pid} = Q
967-
<- mnesia:table(rabbit_queue),
968-
not rabbit_amqqueue:is_mirrored(Q) andalso
969-
node(Pid) == Node andalso
970-
not rabbit_mnesia:is_process_alive(Pid)])),
972+
#amqqueue{name = QName, pid = Pid} =
973+
Q <- mnesia:table(rabbit_queue),
974+
node(Pid) == Node andalso
975+
not rabbit_mnesia:is_process_alive(Pid) andalso
976+
(not rabbit_amqqueue:is_mirrored(Q) orelse
977+
rabbit_amqqueue:is_exclusive(Q))])),
971978
{Qs, Dels} = lists:unzip(QsDels),
972979
T = rabbit_binding:process_deletions(
973980
lists:foldl(fun rabbit_binding:combine_deletions/2,

0 commit comments

Comments
 (0)