summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2014-02-06 17:24:33 +0000
committerMatthias Radestock <matthias@rabbitmq.com>2014-02-06 17:24:33 +0000
commitdd705c894f669587ab3c328be7a6a851ed44080d (patch)
tree58ea50ea9120b4d16c9b10ec2a7e0df4d43f7244
parent7456792ec74cdf72afa7ddc54935b22e933f4316 (diff)
downloadrabbitmq-server-bug25762.tar.gz
minimal fixbug25762
-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)