diff options
| author | Matthias Radestock <matthias@lshift.net> | 2009-04-22 17:57:53 +0100 |
|---|---|---|
| committer | Matthias Radestock <matthias@lshift.net> | 2009-04-22 17:57:53 +0100 |
| commit | 6ea526c16dece49dcf483ce54df450c7dce71986 (patch) | |
| tree | f2f0d2c31b906f3a085d074c6e5f6c78bd9416e1 | |
| parent | 040746724b76cc79c4816439d2cabc44a44740b9 (diff) | |
| download | rabbitmq-server-git-6ea526c16dece49dcf483ce54df450c7dce71986.tar.gz | |
don't conditionally/auto-delete exchanges that still have durable bindings
| -rw-r--r-- | src/rabbit_exchange.erl | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index b70b868d1b..ea74f28993 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -319,15 +319,13 @@ exchanges_for_queue(QueueName) -> sets:from_list( mnesia:select(reverse_route, [{MatchHead, [], ['$1']}]))). -has_bindings(ExchangeName) -> - MatchHead = #route{binding = #binding{exchange_name = ExchangeName, - _ = '_'}}, +contains(Table, MatchHead) -> try - continue(mnesia:select(route, [{MatchHead, [], ['$_']}], 1, read)) + continue(mnesia:select(Table, [{MatchHead, [], ['$_']}], 1, read)) catch exit:{aborted, {badarg, _}} -> %% work around OTP-7025, which was fixed in R12B-1, by %% falling back on a less efficient method - case mnesia:match_object(MatchHead) of + case mnesia:match_object(Table, MatchHead, read) of [] -> false; [_|_] -> true end @@ -471,7 +469,11 @@ maybe_auto_delete(Exchange = #exchange{auto_delete = true}) -> ok. conditional_delete(Exchange = #exchange{name = ExchangeName}) -> - case has_bindings(ExchangeName) of + Match = #route{binding = #binding{exchange_name = ExchangeName, _ = '_'}}, + %% we need to check for durable routes here too in case a bunch of + %% routes to durable queues have been removed temporarily as a + %% result of a node failure + case contains(route, Match) orelse contains(durable_routes, Match) of false -> unconditional_delete(Exchange); true -> {error, in_use} end. |
