Skip to content

Commit 23396e7

Browse files
author
Daniil Fedotov
committed
Allow restart of a vhost message store. purge_messages function to clean message storage (together with message indexes) for a vhost
1 parent c3298b7 commit 23396e7

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/rabbit_msg_store_vhost_sup.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ start_link(Name, ClientRefs, StartupFunState) ->
1313
[Name, ClientRefs, StartupFunState]).
1414

1515
init([Name, ClientRefs, StartupFunState]) ->
16-
{ok, {{simple_one_for_one, 0, 1},
16+
{ok, {{simple_one_for_one, 1, 1},
1717
[{rabbit_msg_store_vhost, {rabbit_msg_store_vhost_sup, start_vhost,
1818
[Name, ClientRefs, StartupFunState]},
1919
transient, infinity, supervisor, [rabbit_msg_store]}]}}.

src/rabbit_vhost.erl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
set_limits/2, limits_of/1]).
2525
-export([info/1, info/2, info_all/0, info_all/1, info_all/2, info_all/3]).
2626
-export([dir/1]).
27-
27+
-export([purge_messages/1]).
2828

2929
-spec add(rabbit_types:vhost()) -> 'ok'.
3030
-spec delete(rabbit_types:vhost()) -> 'ok'.
@@ -94,11 +94,18 @@ delete(VHostPath) ->
9494
with(VHostPath, fun () -> internal_delete(VHostPath) end)),
9595
ok = rabbit_event:notify(vhost_deleted, [{name, VHostPath}]),
9696
[ok = Fun() || Fun <- Funs],
97+
purge_messages(VHostPath),
98+
ok.
99+
100+
purge_messages(VHostPath) ->
97101
VhostDir = filename:join(rabbit_mnesia:dir(), dir(VHostPath)),
98102
rabbit_log:info("Deleting vhost directory '~s'~n", [VhostDir]),
103+
%% Message store is stopped to close file handles
99104
rabbit_variable_queue:stop_vhost_msg_store(VHostPath),
100105
ok = rabbit_file:recursive_delete([VhostDir]),
101-
ok.
106+
%% Second terminate is made in case message store is
107+
%% restarted during deletion
108+
rabbit_variable_queue:stop_vhost_msg_store(VHostPath).
102109

103110
assert_benign(ok) -> ok;
104111
assert_benign({ok, _}) -> ok;

0 commit comments

Comments
 (0)