Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions deps/rabbit/src/rabbit_db_vhost.erl
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,12 @@ with_fun_in_mnesia_tx(VHostName, TxFun)
%% delete().
%% -------------------------------------------------------------------

-spec delete(VHostName) -> ok when
VHostName :: vhost:name().
%% @doc Deletes a virtual host record.
-spec delete(VHostName) -> Existed when
VHostName :: vhost:name(),
Existed :: boolean().
%% @doc Deletes a virtual host record from the database.
%%
%% @returns `ok', even if the record didn't exist before. It throws an
%% @returns a boolean indicating if the vhost existed or not. It throws an
%% exception if the transaction fails.
%%
%% @private
Expand All @@ -315,5 +316,6 @@ delete_in_mnesia(VHostName) ->
fun() -> delete_in_mnesia_tx(VHostName) end).

delete_in_mnesia_tx(VHostName) ->
Existed = mnesia:wread({?MNESIA_TABLE, VHostName}) =/= [],
mnesia:delete({?MNESIA_TABLE, VHostName}),
ok.
Existed.
12 changes: 9 additions & 3 deletions deps/rabbit/src/rabbit_vhost.erl
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,15 @@ delete(VHost, ActingUser) ->
_ = rabbit_runtime_parameters:clear_vhost(VHost, ActingUser),
_ = [rabbit_policy:delete(VHost, proplists:get_value(name, Info), ActingUser)
|| Info <- rabbit_policy:list(VHost)],
ok = rabbit_db_vhost:delete(VHost),
ok = rabbit_event:notify(vhost_deleted, [{name, VHost},
{user_who_performed_action, ActingUser}]),
case rabbit_db_vhost:delete(VHost) of
true ->
ok = rabbit_event:notify(
vhost_deleted,
[{name, VHost},
{user_who_performed_action, ActingUser}]);
false ->
ok
end,
%% After vhost was deleted from the database, we try to stop vhost
%% supervisors on all the nodes.
rabbit_vhost_sup_sup:delete_on_all_nodes(VHost),
Expand Down