|
24 | 24 | set_limits/2, limits_of/1]).
|
25 | 25 | -export([info/1, info/2, info_all/0, info_all/1, info_all/2, info_all/3]).
|
26 | 26 | -export([dir/1]).
|
27 |
| - |
| 27 | +-export([purge_messages/1]). |
28 | 28 |
|
29 | 29 | -spec add(rabbit_types:vhost()) -> 'ok'.
|
30 | 30 | -spec delete(rabbit_types:vhost()) -> 'ok'.
|
@@ -94,11 +94,18 @@ delete(VHostPath) ->
|
94 | 94 | with(VHostPath, fun () -> internal_delete(VHostPath) end)),
|
95 | 95 | ok = rabbit_event:notify(vhost_deleted, [{name, VHostPath}]),
|
96 | 96 | [ok = Fun() || Fun <- Funs],
|
| 97 | + purge_messages(VHostPath), |
| 98 | + ok. |
| 99 | + |
| 100 | +purge_messages(VHostPath) -> |
97 | 101 | VhostDir = filename:join(rabbit_mnesia:dir(), dir(VHostPath)),
|
98 | 102 | rabbit_log:info("Deleting vhost directory '~s'~n", [VhostDir]),
|
| 103 | + %% Message store is stopped to close file handles |
99 | 104 | rabbit_variable_queue:stop_vhost_msg_store(VHostPath),
|
100 | 105 | 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). |
102 | 109 |
|
103 | 110 | assert_benign(ok) -> ok;
|
104 | 111 | assert_benign({ok, _}) -> ok;
|
|
0 commit comments