aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/src
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2016-01-19 16:08:08 +0100
committerDan Gudmundsson <[email protected]>2016-05-09 14:55:36 +0200
commit545d88ac5b1a6bb6fe219c3175e1cafd716f1581 (patch)
tree787d071a3f0d3645aa544abb3ade071281efc762 /lib/mnesia/src
parent3aff6476811a385cf45817d6974b83a6b0345a92 (diff)
downloadotp-545d88ac5b1a6bb6fe219c3175e1cafd716f1581.tar.gz
otp-545d88ac5b1a6bb6fe219c3175e1cafd716f1581.tar.bz2
otp-545d88ac5b1a6bb6fe219c3175e1cafd716f1581.zip
mnesia_ext: Create table/data containers from mnesia monitor not temporary processes
Tables or data containers should be owned and monitored by mnesia_monitor and should thus be created by that process. Always create_table before loading it We need to create tables for ram_copies at least before loading them as they are intermittent. It is also needed to get mnesia monitor as the parent and supervisor of the data storage.
Diffstat (limited to 'lib/mnesia/src')
-rw-r--r--lib/mnesia/src/mnesia_dumper.erl6
-rw-r--r--lib/mnesia/src/mnesia_index.erl5
-rw-r--r--lib/mnesia/src/mnesia_loader.erl16
3 files changed, 18 insertions, 9 deletions
diff --git a/lib/mnesia/src/mnesia_dumper.erl b/lib/mnesia/src/mnesia_dumper.erl
index 845ad0ac39..e404302b71 100644
--- a/lib/mnesia/src/mnesia_dumper.erl
+++ b/lib/mnesia/src/mnesia_dumper.erl
@@ -562,7 +562,7 @@ insert_op(Tid, _, {op, change_table_copy_type, N, FromS, ToS, TabDef}, InPlace,
{{ext,_FromAlias,_FromMod},{ext,ToAlias,ToMod}} ->
disc_delete_table(Tab, FromS),
ok = ToMod:delete_table(ToAlias, Tab),
- ok = ToMod:create_table(ToAlias, Tab, []),
+ ok = mnesia_monitor:unsafe_create_external(Tab, ToAlias, ToMod, TabDef),
ok = ToMod:load_table(ToAlias, Tab, {dumper,change_table_copy_type}, TabDef),
ok = load_from_logfile(ToS, Tab, Logtmp),
file:delete(Logtmp),
@@ -582,7 +582,7 @@ insert_op(Tid, _, {op, change_table_copy_type, N, FromS, ToS, TabDef}, InPlace,
end,
ok = ToMod:delete_table(ToAlias, Tab),
- ok = ToMod:create_table(ToAlias, Tab, []),
+ ok = mnesia_monitor:unsafe_create_external(Tab, ToAlias, ToMod, TabDef),
ok = ToMod:load_table(ToAlias, Tab, {dumper,change_table_copy_type}, TabDef),
ok = load_from_logfile(ToS, Tab, Logtmp),
file:delete(Logtmp),
@@ -1401,6 +1401,8 @@ load_from_logfile(Storage, Tab, F) ->
{linkto, self()}]) of
{ok, Fd} ->
chunk_from_log(disk_log:chunk(Fd, start), Fd, Storage, Tab);
+ {repaired, Fd, _, _} ->
+ chunk_from_log(disk_log:chunk(Fd, start), Fd, Storage, Tab);
{error, _} = E ->
E
end.
diff --git a/lib/mnesia/src/mnesia_index.erl b/lib/mnesia/src/mnesia_index.erl
index 902d0c12ae..d5bd6d7125 100644
--- a/lib/mnesia/src/mnesia_index.erl
+++ b/lib/mnesia/src/mnesia_index.erl
@@ -348,9 +348,10 @@ init_ext_index(_, _, _, _, []) ->
init_ext_index(Tab, Storage, Alias, Mod, [{Pos,Type} | Tail]) ->
PosInfo = {Pos, Type},
IxTag = {Tab, index, PosInfo},
- _Res = Mod:create_table(Alias, IxTag, []),
CS = val({Tab, cstruct}),
- Mod:load_table(Alias, IxTag, init_index, mnesia_schema:cs2list(CS)),
+ CsList = mnesia_schema:cs2list(CS),
+ _Res = mnesia_monitor:unsafe_create_external(IxTag, Alias, Mod, CsList),
+ Mod:load_table(Alias, IxTag, init_index, CsList),
case Mod:is_index_consistent(Alias, IxTag) of
false ->
Mod:index_is_consistent(Alias, IxTag, false),
diff --git a/lib/mnesia/src/mnesia_loader.erl b/lib/mnesia/src/mnesia_loader.erl
index 93660007f1..67afef6f8c 100644
--- a/lib/mnesia/src/mnesia_loader.erl
+++ b/lib/mnesia/src/mnesia_loader.erl
@@ -150,11 +150,17 @@ do_get_disc_copy2(Tab, Reason, Storage, Type) when Storage == disc_only_copies -
end;
do_get_disc_copy2(Tab, Reason, Storage = {ext, Alias, Mod}, _Type) ->
- ok = ext_load_table(Mod, Alias, Tab, Reason),
- mnesia_index:init_index(Tab, Storage),
- set({Tab, load_node}, node()),
- set({Tab, load_reason}, Reason),
- {loaded, ok}.
+ Cs = val({Tab, cstruct}),
+ case mnesia_monitor:unsafe_create_external(Tab, Alias, Mod, Cs) of
+ ok ->
+ ok = ext_load_table(Mod, Alias, Tab, Reason),
+ mnesia_index:init_index(Tab, Storage),
+ set({Tab, load_node}, node()),
+ set({Tab, load_reason}, Reason),
+ {loaded, ok};
+ Other ->
+ {not_loaded, Other}
+ end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Load a table from a remote node