Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 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: 11 additions & 1 deletion lib/mnesia/src/mnesia_controller.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,17 @@ handle_info(Done = #loader_done{worker_pid=WPid, table_name=Tab}, State0) ->
DelState = State1#state{late_loader_queue=gb_trees:delete_any(Tab, LateQueue0)},
cast({disc_load, Tab, ram_only}),
DelState;
{_, []} -> %% Table deleted or not loaded anywhere
{_, []} ->
case val({Tab, load_by_force}) of
true ->
%% Network load could have failed, and user forced the load,
%% retry loading again from disk
%% TODO: Can this go into infinite loop?
cast({disc_load, Tab, forced_by_user});
_ ->
ok
end,
%% Table deleted or not loaded anywhere
State1#state{late_loader_queue=gb_trees:delete_any(Tab, LateQueue0)}
end
end,
Expand Down
6 changes: 4 additions & 2 deletions lib/mnesia/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ MODULES= \
ext_test \
ext_test_server \
mnesia_index_plugin_test \
mnesia_external_backend_test
mnesia_external_backend_test \
gen_tcp_blocking_dist

DocExamplesDir := ../doc/src/

Expand All @@ -77,7 +78,7 @@ ExampleModules = \

ERL_FILES= $(MODULES:%=%.erl) $(DocExampleModules:%=$(DocExamplesDir)/%.erl) $(ExampleModules:%=$(ExamplesDir)/%.erl)

HRL_FILES= mnesia_test_lib.hrl ext_test_server.hrl $(DocExamplesHrl:%=$(DocExamplesDir)/%)
HRL_FILES= mnesia_test_lib.hrl ext_test_server.hrl gen_tcp_blocking_dist.hrl $(DocExamplesHrl:%=$(DocExamplesDir)/%)

TARGET_FILES= \
$(MODULES:%=$(EBIN)/%.$(EMULATOR)) $(DocExampleModules:%=$(EBIN)/%.$(EMULATOR)) $(ExampleModules:%=$(EBIN)/%.$(EMULATOR))
Expand All @@ -93,6 +94,7 @@ RELSYSDIR = $(RELEASE_PATH)/mnesia_test
# FLAGS
# ----------------------------------------------------
#ERL_COMPILE_FLAGS +=
ERL_COMPILE_FLAGS += +nowarn_missing_spec_documented -Werror
ERL_COMPILE_FLAGS := $(filter-out +deterministic,$(ERL_COMPILE_FLAGS))

EBIN = .
Expand Down
4 changes: 2 additions & 2 deletions lib/mnesia/test/ext_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ delete_table(Alias, Tab) ->
try error_if_not_initialized() of
ok ->
call({?FUNCTION_NAME, Alias, Tab})
catch error : {backend_not_initialized, _} = Reason ->
catch error : {backend_not_initialized, _} = _Reason ->
ok
end.

Expand Down Expand Up @@ -253,7 +253,7 @@ repair_continuation(Cont, Ms) ->
call(Req) ->
error_if_not_initialized(),
case gen_server:call({global, mnesia_test_lib:get_ext_test_server_name()}, Req) of
#exception{c = Class, r = Reason, st = ST} = Ex ->
#exception{c = Class, r = Reason, st = ST} = _Ex ->
?DBG("call ~p resulted in an exception: ~p~n", [Req, Ex]),
Comment thread
Mikaka27 marked this conversation as resolved.
Outdated
erlang:raise(Class, Reason, ST);
Res ->
Expand Down
34 changes: 17 additions & 17 deletions lib/mnesia/test/ext_test_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ init(_) ->

create_table(ext_ram_copies, Tab, Props, #state{tables = Tables} = State) when is_atom(Tab) ->
case maps:get(Tab, Tables, undefined) of
#table{state = opened, tid = Tid} ->
?DBG("create_table, Alias: ext_ram_copies, Tab: ~p(~p) is already opened~n", [tab_to_list(Tab), Tid]),
#table{state = opened, tid = _Tid} ->
?DBG("create_table, Alias: ext_ram_copies, Tab: ~p(~p) is already opened~n", [tab_to_list(Tab), _Tid]),
{ok, State};
_ ->
?DBG("create_table, Alias: ext_ram_copies, Tab: ~p~n", [tab_to_list(Tab)]),
Expand All @@ -62,18 +62,18 @@ create_table(ext_disc_only_copies, Tab, Props, #state{tables = Tables} = State)
?DBG("create_table Alias: ext_disc_only_copies after dets:open_file, Tab: ~p~n", [tab_to_list(Tab)]),
{ok, State#state{tables = maps:put(Tab, #table{state = opened, tid = Tab}, Tables)}}
end;
create_table(ext_ram_copies, Tag={Tab, index, {_Where, Type}}, _Opts, #state{tables = Tables} = State) ->
create_table(ext_ram_copies, Tag={_Tab, index, {_Where, Type}}, _Opts, #state{tables = Tables} = State) ->
case maps:get(Tag, Tables, undefined) of
#table{state = opened, tid = Tid} ->
?DBG("create_table, Alias: ext_ram_copies, Tab: ~p(~p) is already opened~n", [tab_to_list(Tag), Tid]),
#table{state = opened, tid = _Tid} ->
?DBG("create_table, Alias: ext_ram_copies, Tab: ~p(~p) is already opened~n", [tab_to_list(Tag), _Tid]),
{ok, State};
_ ->
?DBG("create_table, Alias: ext_ram_copies, Tab: ~p~n", [tab_to_list(Tag)]),
Tid = ets:new(tab_to_atom(Tag), [public, type_to_type_in_alias(ext_ram_copies, Type)]),
?DBG("create_table, Alias, ext_ram_copies, Tab: ~p(~p)~n", [tab_to_list(Tag), Tid]),
{ok, State#state{tables = maps:put(Tag, #table{state = opened, tid = Tid}, Tables)}}
end;
create_table(ext_disc_only_copies, Tag={Tab, index, {_Where, Type}}, _Opts, #state{tables = Tables} = State) ->
create_table(ext_disc_only_copies, Tag={_Tab, index, {_Where, Type}}, _Opts, #state{tables = Tables} = State) ->
case maps:get(Tag, Tables, undefined) of
#table{state = opened, tid = Tag} ->
?DBG("create_table, Alias: ext_disc_only_copies, Tab: ~p(~p) is already opened~n", [tab_to_list(Tag), Tag]),
Expand All @@ -85,18 +85,18 @@ create_table(ext_disc_only_copies, Tag={Tab, index, {_Where, Type}}, _Opts, #sta
?DBG("create_table Alias: ext_disc_only_copies after dets:open_file, Tab: ~p~n", [tab_to_list(Tag)]),
{ok, State#state{tables = maps:put(Tag, #table{state = opened, tid = Tag}, Tables)}}
end;
create_table(ext_ram_copies, Tag={_Tab, retainer, ChkPName}, _Opts, #state{tables = Tables} = State) ->
create_table(ext_ram_copies, Tag={_Tab, retainer, _ChkPName}, _Opts, #state{tables = Tables} = State) ->
case maps:get(Tag, Tables, undefined) of
#table{state = opened, tid = Tid} ->
?DBG("create_table, Alias: ext_ram_copies, Tab: ~p(~p) is already opened~n", [tab_to_list(Tag), Tid]),
#table{state = opened, tid = _Tid} ->
?DBG("create_table, Alias: ext_ram_copies, Tab: ~p(~p) is already opened~n", [tab_to_list(Tag), _Tid]),
{ok, State};
_ ->
?DBG("create_table, Alias: ext_ram_copies, Tab: ~p~n", [tab_to_list(Tag)]),
Tid = ets:new(tab_to_atom(Tag), [set, public, {keypos, 2}]),
?DBG("create_table, Alias, ext_ram_copies, Tab: ~p(~p)~n", [tab_to_list(Tag), Tid]),
{ok, State#state{tables = maps:put(Tag, #table{state = opened, tid = Tid}, Tables)}}
end;
create_table(ext_disc_only_copies, Tag={_Tab, retainer, ChkPName}, _Opts, #state{tables = Tables} = State) ->
create_table(ext_disc_only_copies, Tag={_Tab, retainer, _ChkPName}, _Opts, #state{tables = Tables} = State) ->
case maps:get(Tag, Tables, undefined) of
#table{state = opened, tid = Tag} ->
?DBG("create_table, Alias: ext_disc_only_copies, Tab: ~p(~p) is already opened~n", [tab_to_list(Tag), Tag]),
Expand All @@ -109,15 +109,15 @@ create_table(ext_disc_only_copies, Tag={_Tab, retainer, ChkPName}, _Opts, #state
{ok, State#state{tables = maps:put(Tag, #table{state = opened, tid = Tag}, Tables)}}
end.

receive_data(Data, ext_ram_copies, Name, Sender, {Name, Tab, Sender} = MnesiaState, State) ->
receive_data(Data, ext_ram_copies, Name, Sender, {Name, Tab, Sender} = _MnesiaState, State) ->
?DBG({Data, ext_ram_copies, Name, Sender, {Name, tab_to_list(Tab), Sender}}),
true = ets:insert(tab_to_tid(Tab, State), Data),
{more, State};
receive_data(Data, ext_disc_only_copies, Name, Sender, {Name, Tab, Sender} = MnesiaState, State) ->
receive_data(Data, ext_disc_only_copies, Name, Sender, {Name, Tab, Sender} = _MnesiaState, State) ->
?DBG({Data, ext_disc_only_copies, Name, Sender, {Name, tab_to_list(Tab), Sender}}),
ok = dets:insert(tab_to_tid(Tab, State), Data),
{more, State};
receive_data(Data, Alias, Tab, Sender, {Name, Sender} = MnesiaState, State) ->
receive_data(Data, Alias, Tab, Sender, {Name, Sender} = _MnesiaState, State) ->
?DBG({Data, Alias, tab_to_list(Tab), State}),
receive_data(Data, Alias, Tab, Sender, {Name, Tab, Sender}, State).

Expand Down Expand Up @@ -162,7 +162,7 @@ handle_call({delete_table, ext_ram_copies, Tab}, _From, #state{tables = Tables}
case ?TRY(ets:delete(Tid)) of
#exception{} = Res ->
{reply, Res, State};
Res ->
_Res ->
NewState = State#state{tables = maps:remove(Tab, Tables)},
{reply, ok, NewState}
end;
Expand Down Expand Up @@ -395,8 +395,8 @@ handle_call({repair_continuation, ext_ram_copies, Cont, Ms}, _From, State) ->
Res = ?TRY(ets:repair_continuation(Cont, Ms)),
{reply, Res, State}.

terminate(Reason, _State) ->
?DBG(Reason).
terminate(_Reason, _State) ->
?DBG(_Reason).

code_change(_OldVsn, State, _Extra) ->
{ok, State}.
Expand Down Expand Up @@ -425,4 +425,4 @@ tab_to_filename(Tab) ->

tab_to_tid(Tab, #state{tables = Tables}) ->
Table = maps:get(Tab, Tables),
Table#table.tid.
Table#table.tid.
Loading