Skip to content

Commit 2209b0b

Browse files
committed
Move the code to clear RAM tables to rabbit_table
[Why] Because it is specific to Mnesia and the logic has nothing to do in the generic `rabbit` module. [How] A new `rabbit_table:maybe_clear_ram_only_tables/0` is introduced.
1 parent 16e8d1f commit 2209b0b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

deps/rabbit/src/rabbit.erl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,10 +1038,7 @@ prep_stop(State) ->
10381038

10391039
stop(State) ->
10401040
ok = rabbit_alarm:stop(),
1041-
ok = case rabbit_db_cluster:is_clustered() of
1042-
true -> ok;
1043-
false -> rabbit_table:clear_ram_only_tables()
1044-
end,
1041+
ok = rabbit_table:maybe_clear_ram_only_tables(),
10451042
case State of
10461043
[] -> rabbit_prelaunch:set_stop_reason(normal);
10471044
_ -> rabbit_prelaunch:set_stop_reason(State)

deps/rabbit/src/rabbit_table.erl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
create/0, create/2, ensure_local_copies/1, ensure_table_copy/3,
1212
wait_for_replicated/1, wait/1, wait/2,
1313
force_load/0, is_present/0, is_empty/0, needs_default_data/0,
14-
check_schema_integrity/1, clear_ram_only_tables/0, retry_timeout/0,
15-
wait_for_replicated/0]).
14+
check_schema_integrity/1,
15+
clear_ram_only_tables/0, maybe_clear_ram_only_tables/0,
16+
retry_timeout/0, wait_for_replicated/0]).
1617

1718
%% for testing purposes
1819
-export([definitions/0]).
@@ -191,6 +192,12 @@ clear_ram_only_tables() ->
191192
end, names()),
192193
ok.
193194

195+
maybe_clear_ram_only_tables() ->
196+
ok = case rabbit_db_cluster:is_clustered() of
197+
true -> ok;
198+
false -> clear_ram_only_tables()
199+
end.
200+
194201
%% The sequence in which we delete the schema and then the other
195202
%% tables is important: if we delete the schema first when moving to
196203
%% RAM mnesia will loudly complain since it doesn't make much sense to

0 commit comments

Comments
 (0)