Skip to content

Commit ec9a108

Browse files
committed
mnesia: Discard old irrelevant msgs
During startup we postpone handling certain messages until after schema merge, they may be invalid and if so discard them. For example the {i_have_tab, Tab, Node} where the table copy have been deleted on the Node, should not be handled.
1 parent 0418c10 commit ec9a108

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

lib/mnesia/src/mnesia_controller.erl

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,17 +1485,25 @@ orphan_tables([Tab | Tabs], Node, Ns, Local, Remote) ->
14851485
orphan_tables([], _, _, LocalOrphans, RemoteMasters) ->
14861486
{LocalOrphans, RemoteMasters}.
14871487

1488-
node_has_tabs([Tab | Tabs], Node, State) when Node /= node() ->
1489-
State2 =
1490-
try update_whereabouts(Tab, Node, State) of
1491-
State1 = #state{} -> State1
1492-
catch exit:R -> %% Tab was just deleted?
1493-
case ?catch_val({Tab, cstruct}) of
1494-
{'EXIT', _} -> State; % yes
1495-
_ -> erlang:error(R)
1496-
end
1497-
end,
1498-
node_has_tabs(Tabs, Node, State2);
1488+
node_has_tabs([Tab | Tabs], Node, State0) when Node /= node() ->
1489+
State = try
1490+
case ?catch_val({Tab, cstruct}) of
1491+
{'EXIT', _} -> State0;
1492+
Cs ->
1493+
case mnesia_lib:cs_to_storage_type(Node, Cs) of
1494+
unknown -> %% handle_early_msgs may come with obsolete
1495+
State0; %% information, if irrelevant ignore it.
1496+
_ ->
1497+
#state{} = update_whereabouts(Tab, Node, State0)
1498+
end
1499+
end
1500+
catch exit:R:ST -> %% Tab was just deleted?
1501+
case ?catch_val({Tab, cstruct}) of
1502+
{'EXIT', _} -> State0; % yes
1503+
_ -> erlang:error({R, ST})
1504+
end
1505+
end,
1506+
node_has_tabs(Tabs, Node, State);
14991507
node_has_tabs([Tab | Tabs], Node, State) ->
15001508
user_sync_tab(Tab),
15011509
node_has_tabs(Tabs, Node, State);

0 commit comments

Comments
 (0)