summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2014-02-10 16:05:55 +0000
committerSimon MacMullen <simon@rabbitmq.com>2014-02-10 16:05:55 +0000
commit0a7addc288aecb035525410d65279d65501c0431 (patch)
treebcb08f2abb02a4497c9dbc614f05736c02d2df3f
parent86f42d904a8a9b6cfdc65379e471d48f5ad714f6 (diff)
parente7aeb758bbc2b808b4ac63ae13c3b3200cd68d9e (diff)
downloadrabbitmq-server-0a7addc288aecb035525410d65279d65501c0431.tar.gz
Merge bug 26000 (into stable this time)
-rw-r--r--src/rabbit_tests.erl3
-rw-r--r--src/rabbit_vhost.erl16
2 files changed, 17 insertions, 2 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index 5fe319d3..4676c0d6 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -1042,6 +1042,9 @@ test_user_management() ->
ok = control_action(add_vhost, ["/testhost"]),
ok = control_action(set_permissions, ["foo", ".*", ".*", ".*"],
[{"-p", "/testhost"}]),
+ {new, _} = rabbit_amqqueue:declare(
+ rabbit_misc:r(<<"/testhost">>, queue, <<"test">>),
+ true, false, [], none),
ok = control_action(delete_vhost, ["/testhost"]),
%% user deletion
diff --git a/src/rabbit_vhost.erl b/src/rabbit_vhost.erl
index 8d013d43..b0350e86 100644
--- a/src/rabbit_vhost.erl
+++ b/src/rabbit_vhost.erl
@@ -81,9 +81,9 @@ delete(VHostPath) ->
%% eventually the termination of that process. Exchange deletion causes
%% notifications which must be sent outside the TX
rabbit_log:info("Deleting vhost '~s'~n", [VHostPath]),
- [{ok,_} = rabbit_amqqueue:delete(Q, false, false) ||
+ [assert_benign(rabbit_amqqueue:delete(Q, false, false)) ||
Q <- rabbit_amqqueue:list(VHostPath)],
- [ok = rabbit_exchange:delete(Name, false) ||
+ [assert_benign(rabbit_exchange:delete(Name, false)) ||
#exchange{name = Name} <- rabbit_exchange:list(VHostPath)],
R = rabbit_misc:execute_mnesia_transaction(
with(VHostPath, fun () ->
@@ -92,6 +92,18 @@ delete(VHostPath) ->
ok = rabbit_event:notify(vhost_deleted, [{name, VHostPath}]),
R.
+assert_benign(ok) -> ok;
+assert_benign({ok, _}) -> ok;
+assert_benign({error, not_found}) -> ok;
+assert_benign({error, {absent, Q}}) ->
+ %% We have a durable queue on a down node. Removing the mnesia
+ %% entries here is safe. If/when the down node restarts, it will
+ %% clear out the on-disk storage of the queue.
+ case rabbit_amqqueue:internal_delete(Q#amqqueue.name) of
+ ok -> ok;
+ {error, not_found} -> ok
+ end.
+
internal_delete(VHostPath) ->
[ok = rabbit_auth_backend_internal:clear_permissions(
proplists:get_value(user, Info), VHostPath)